Update edit modale porta

This commit is contained in:
Samuele Locatelli
2023-06-01 17:03:01 +02:00
parent aac9ef28c6
commit 72b762b4b5
8 changed files with 56 additions and 13 deletions
@@ -659,6 +659,9 @@ namespace WebDoorCreator.Data.Controllers
if (currRec != null) //if is not null edit the record found
{
currRec.Quantity = addEditRec.Quantity;
currRec.DoorExtCode= addEditRec.DoorExtCode;
currRec.DoorDescript= addEditRec.DoorDescript;
currRec.TypeId = addEditRec.TypeId;
localDbCtx.Entry(currRec).State = EntityState.Modified;
}
else //if is null add the record as new in the table
+35
View File
@@ -116,5 +116,40 @@ namespace WebDoorCreator.Data.DbModels
};
return answ;
}
public override bool Equals(object? obj)
{
if (obj == null)
return false;
if (!(obj is DoorModel item))
return false;
if (Quantity != item.Quantity)
return false;
if (DoorExtCode != item.DoorExtCode)
return false;
if (DoorDescript != item.DoorDescript)
return false;
//if (OrderId != item.OrderId)
// return false;
//if (MeasureUnit != item.MeasureUnit)
// return false;
//if (UnitCost != item.UnitCost)
// return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
@@ -198,6 +198,5 @@ namespace WebDoorCreator.Data.DbModels
return answ;
}
}
}
@@ -65,5 +65,6 @@ namespace WebDoorCreator.Data.DbModels
[ForeignKey("CompanyId")]
public virtual CompanyModel? CompanyNav { get; set; }
}
}
@@ -1047,6 +1047,8 @@ namespace WebDoorCreator.Data.Services
pattern = new RedisValue($"{Constants.rKeyDoor}:{DoorId}:*");
}
bool answ = await ExecFlushRedisPattern(pattern);
pattern = new RedisValue($"{Constants.rKeyDoorsByOrder}:*");
answ = await ExecFlushRedisPattern(pattern);
return answ;
}
@@ -309,7 +309,7 @@ namespace WebDoorCreator.UI.Components.DoorMan
{
Dictionary<string, string> answ = new Dictionary<string, string>();
answ.Add("Doors #:", $"{door.Quantity}");
answ.Add("Model #:", $"{door.TypeId}");
answ.Add($"{door.DoorExtCode} {door.DoorDescript}","");
answ.Add("Door Price:", $"{(door.Quantity * door.UnitCost):C2}");
return answ;
}
@@ -4,20 +4,22 @@
<div>
<b class="fs-3">@($"Door ID: {CurrDoor.DoorId}")</b>
</div>
<div>
<span class="closeOrd" @onclick="()=>closeModal()">&times;</span>
<div class="d-flex">
<div>
@if (!CurrDoor.Equals(CurrDoorClone))
{
<button class="btn btn-secondary" type="button" @onclick="()=>ReloadData()">Cancel <i class="fa-solid fa-xmark"></i></button>
<button class="btn btn-success" type="button" @onclick="()=>UpdateDoor(true)">Update <i class="fa-solid fa-check"></i></button>
}
</div>
<div>
<span class="closeOrd" @onclick="()=>closeModal()">&times;</span>
</div>
</div>
</div>
<div class="row">
<div class="w-25">
<div class="pb-1">
<div class="d-flex justify-content-between mb-3">
@if (CurrDoorClone.Quantity != CurrDoor.Quantity)
{
<button class="btn btn-outline-danger" type="button" @onclick="()=>ReloadData()">CANCEL</button>
<button class="btn btn-outline-success" type="button" @onclick="()=>ChangeDoorNumber(true)">CONFIRM</button>
}
</div>
<div class="d-flex justify-content-between mb-2 small">
<div class="form-floating mb-1">
<input type="text" @bind="@CurrDoor.DoorExtCode" class="form-control" placeholder="Enter Code">
@@ -101,9 +101,10 @@ namespace WebDoorCreator.UI.Components.DoorMan
}
}
protected async Task ChangeDoorNumber(bool isAdd)
protected async Task UpdateDoor(bool isAdd)
{
var done = await WDService.DoorModQty(doorQty, CurrDoor.OrderId, CurrDoor.DoorId, isAdd);
//var done = await WDService.DoorModQty(doorQty, CurrDoor.OrderId, CurrDoor.DoorId, isAdd);
var done = await WDService.DoorUpsert(CurrDoor);
if (done)
{
await ReloadData();