inizio gestione porte
This commit is contained in:
@@ -27,19 +27,18 @@ namespace WebDoorCreator.Data.Controllers
|
||||
#region Company methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco Company (ALL)
|
||||
/// Company list (All)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<CompanyModel> CompanyAll()
|
||||
{
|
||||
// init dati necessari
|
||||
List<CompanyModel> dbResult = new List<CompanyModel>();
|
||||
// cerco su DB recuperando set di dati....
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero intero set...
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetCompany
|
||||
.OrderBy(x => x.CompanyName)
|
||||
@@ -147,7 +146,7 @@ namespace WebDoorCreator.Data.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero intero set...
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsersView
|
||||
.OrderBy(x => x.UserId)
|
||||
@@ -172,7 +171,7 @@ namespace WebDoorCreator.Data.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero intero set...
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsers
|
||||
.OrderBy(x => x.Id)
|
||||
@@ -197,7 +196,7 @@ namespace WebDoorCreator.Data.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero intero set...
|
||||
// extracting entire set
|
||||
var risultato = localDbCtx
|
||||
.DbSetUsers
|
||||
.Where(x => x.Id == userId)
|
||||
@@ -237,7 +236,7 @@ namespace WebDoorCreator.Data.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero intero set...
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetRoles
|
||||
.OrderBy(x => x.Name)
|
||||
@@ -322,5 +321,76 @@ namespace WebDoorCreator.Data.Controllers
|
||||
}
|
||||
|
||||
#endregion Order methods
|
||||
|
||||
#region Door methods
|
||||
|
||||
/// <summary>
|
||||
/// Getting door data by orderId
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DoorModel> DoorsGetByOrderId(int orderId)
|
||||
{
|
||||
List<DoorModel> dbResult = new List<DoorModel>();
|
||||
// retrieving data from db
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x=>x.OrderId == orderId)
|
||||
.OrderBy(x => x.DoorId)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in DoorsGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifying or adding a new door
|
||||
/// </summary>
|
||||
/// <param name="addEditRec">Record to edit or add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorsAddMod(DoorModel addEditRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
//List<ItemModel> dbResult = new List<ItemModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == addEditRec.DoorId)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null) //if is not null edit the record found
|
||||
{
|
||||
currRec.Quantity = addEditRec.Quantity;
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else //if is null add the record as new in the table
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetDoor
|
||||
.Add(addEditRec);
|
||||
}
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorsAddMod: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Door methods
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ else
|
||||
@foreach (var item in ListOrdersStatus)
|
||||
{
|
||||
<tr>
|
||||
<td><button class="btn btn-sm btn-warning"><i class="fa-solid fa-pen-to-square"></i></button></td>
|
||||
<td><button class="btn btn-sm btn-warning" data-bs-toggle="modal" data-bs-target="#OrderDetailModal" @onclick="()=>setCurrOrder(item.OrderId)"><i class="fa-solid fa-pen-to-square"></i></button></td>
|
||||
<td>@item.DateIns</td>
|
||||
<td>@item.OrderId</td>
|
||||
<td>@item.OrderDescript</td>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace WebDoorCreator.UI.Components
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<OrderStatusViewModel> E_currOrderStatus { get; set; }
|
||||
public EventCallback<int> E_currOrderStatus { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -66,9 +66,10 @@ namespace WebDoorCreator.UI.Components
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
private async Task setCurrOrder(string userId)
|
||||
private async Task setCurrOrder(int userId)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
await E_currOrderStatus.InvokeAsync(userId);
|
||||
}
|
||||
|
||||
protected string setPgColor(int progress)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<OrderList></OrderList>
|
||||
<OrderList E_currOrderStatus="catchCurrOrder"></OrderList>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal Order -->
|
||||
@@ -49,6 +49,44 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal Door -->
|
||||
<div class="modal fade" id="OrderDetailModal" tabindex="-1" aria-labelledby="OrderDetailModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="newCompModalLabel">Insert new company</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="w-100">
|
||||
|
||||
@if (DoorsList != null)
|
||||
{
|
||||
@foreach (var door in DoorsList)
|
||||
{
|
||||
<button class="btn btn-sm btn-danger"><i class="fa-solid fa-pen-to-square"></i></button>
|
||||
<input value="@door.DoorExtCode" disabled/>
|
||||
<input @bind-value="@door.Quantity" type="number" />
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@* <div class="form-floating">
|
||||
<input id="orderCodExt" @bind-value="@orderCodExt" class="form-control w-100 w-100w-100 my-1" />
|
||||
<label for="orderCodExt" class="form-label">Order external code</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<textarea id="orderDescr" @bind="@orderDescr" class="form-control w-100" rows="3"></textarea>
|
||||
<label for="orderDescr" class="form-label">Order description</label>
|
||||
</div>*@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" @onclick="()=>addNewOrder(context.User.Identity?.Name!)">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
|
||||
@@ -61,10 +61,12 @@ namespace WebDoorCreator.UI.Pages
|
||||
|
||||
protected List<UsersViewModel>? UsersList { get; set; } = null;
|
||||
protected List<AspNetRoles>? RolesList { get; set; } = null;
|
||||
protected List<DoorModel>? DoorsList { get; set; } = null;
|
||||
|
||||
protected AspNetUsers? currUser { get; set; } = null;
|
||||
|
||||
protected bool isModRole { get; set; } = false;
|
||||
protected int currDoorType { get; set; } = 0;
|
||||
|
||||
protected async Task addNewOrder(string userName)
|
||||
{
|
||||
@@ -84,12 +86,50 @@ namespace WebDoorCreator.UI.Pages
|
||||
|
||||
var done = await WDService.OrderAdd(addRec);
|
||||
|
||||
if(done)
|
||||
if (done)
|
||||
{
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task SetCurrDoorType(int doorType)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
currDoorType = doorType;
|
||||
}
|
||||
|
||||
|
||||
protected async Task addOrModDoor(string userName)
|
||||
{
|
||||
var user = await _userManager.FindByNameAsync(userName);
|
||||
|
||||
DoorModel? addRec = new DoorModel();
|
||||
|
||||
if (currDoorType != 0)
|
||||
{
|
||||
if (DoorsList != null)
|
||||
{
|
||||
addRec = DoorsList.Where(x => x.TypeId == currDoorType).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (addRec != null)
|
||||
{
|
||||
|
||||
var done = await WDService.DoorsAddMod(addRec);
|
||||
|
||||
if (done)
|
||||
{
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task catchCurrOrder(int orderId)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
DoorsList = await WDService.DoorsGetByOrderId(orderId);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user