Merge branch 'feature/UpgradeDoorDataModel' of https://gitlab.steamware.net/egalware-web/special/webdoorcreator into feature/UpgradeDoorDataModel
This commit is contained in:
@@ -9,63 +9,16 @@ namespace WebDoorCreator.Data.Controllers
|
||||
{
|
||||
public class WebDoorCreatorController : IDisposable
|
||||
{
|
||||
private static IConfiguration _configuration;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
#region Public Constructors
|
||||
|
||||
public WebDoorCreatorController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
//Log.Info("Dispose di GWMSController");
|
||||
}
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Company methods
|
||||
|
||||
/// <summary>
|
||||
/// Company list (All)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<CompanyModel> CompanyGetByKey(int id)
|
||||
{
|
||||
List<CompanyModel> dbResult = new List<CompanyModel>();
|
||||
// cerco su DB recuperando set di dati....
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetCompany
|
||||
.OrderBy(x => x.CompanyName)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var risultato = localDbCtx
|
||||
.DbSetCompany
|
||||
.Where(x => x.CompanyId == id)
|
||||
.OrderBy(x => x.CompanyName)
|
||||
.ToList();
|
||||
if (risultato != null)
|
||||
{
|
||||
dbResult = risultato;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in CompanyAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new company
|
||||
@@ -115,198 +68,357 @@ namespace WebDoorCreator.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Company methods
|
||||
|
||||
#region User methods
|
||||
|
||||
/// <summary>
|
||||
/// Populating DTO to handle users
|
||||
/// </summary>
|
||||
/// <param name="userId">User id to search for</param>
|
||||
/// <returns></returns>
|
||||
public List<UserRoleClaimDTO> GetUserRoleClaimByUserId()
|
||||
{
|
||||
List<UserRoleClaimDTO> dbResult = new List<UserRoleClaimDTO>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
var users = localDbCtx.DbSetUsers.ToList();
|
||||
|
||||
foreach (var item in users)
|
||||
{
|
||||
var userRoles = localDbCtx.DbSetUserRoles
|
||||
.Where(x => x.UserId == item.Id)
|
||||
.Include(u => u.UsersNav)
|
||||
.Include(u => u.RolesNav)
|
||||
.ToList();
|
||||
|
||||
//UserRoleClaimDTO userDTO = new UserRoleClaimDTO()
|
||||
//{
|
||||
// userName = item.UserName,
|
||||
// rolesName = userRoles
|
||||
//};
|
||||
//dbResult.Add(userDTO);
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieving data from user/roles relation
|
||||
/// Company list (All)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<UsersViewModel> GetUserView()
|
||||
public List<CompanyModel> CompanyGetByKey(int id)
|
||||
{
|
||||
List<UsersViewModel> dbResult = new List<UsersViewModel>();
|
||||
List<CompanyModel> dbResult = new List<CompanyModel>();
|
||||
// cerco su DB recuperando set di dati....
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsersView
|
||||
.OrderBy(x => x.UserId)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieving data from users table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AspNetUsers> GetUsersAll()
|
||||
{
|
||||
List<AspNetUsers> dbResult = new List<AspNetUsers>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsers
|
||||
.OrderBy(x => x.Id)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieving data from users table filtered by id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AspNetUsers GetUsersById(string userId)
|
||||
{
|
||||
AspNetUsers dbResult = new AspNetUsers();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
var risultato = localDbCtx
|
||||
.DbSetUsers
|
||||
.Where(x => x.Id == userId)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Id)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (risultato != null)
|
||||
if (id == 0)
|
||||
{
|
||||
dbResult = risultato;
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetCompany
|
||||
.OrderBy(x => x.CompanyName)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = new AspNetUsers();
|
||||
var risultato = localDbCtx
|
||||
.DbSetCompany
|
||||
.Where(x => x.CompanyId == id)
|
||||
.OrderBy(x => x.CompanyName)
|
||||
.ToList();
|
||||
if (risultato != null)
|
||||
{
|
||||
dbResult = risultato;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetUsersById:{Environment.NewLine}{exc}");
|
||||
Log.Error($"Error in CompanyAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion User methods
|
||||
/// <summary>
|
||||
/// Adding a new Compo
|
||||
/// </summary>
|
||||
/// <param name="addRec">Record to add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CompoAdd(HardwareModel addRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetHardware
|
||||
.Add(addRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante CompoAdd: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#region Roles methods
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
//Log.Info("Dispose di GWMSController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieving data from roles table
|
||||
/// Remove door
|
||||
/// </summary>
|
||||
/// <param name="DoorId">ID da eliminare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorDelete(int DoorId)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == DoorId)
|
||||
.FirstOrDefault();
|
||||
// procedo solo se c'è
|
||||
if (currRec != null)
|
||||
{
|
||||
var newDbRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Remove(currRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorDelete: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new door
|
||||
/// </summary>
|
||||
/// <param name="newRec">Record to edit or add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> DoorInsert(DoorModel newRec)
|
||||
{
|
||||
int newId = 0;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == newRec.DoorId)
|
||||
.FirstOrDefault();
|
||||
// procedo solo se non c'è già
|
||||
if (currRec == null)
|
||||
{
|
||||
var newDbRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Add(newRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
newId = newRec.DoorId;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding or removing a single door
|
||||
/// </summary>
|
||||
/// <param name="doorId">Record id to edit or add</param>
|
||||
/// <param name="isAdd">States if it has to be added or removing a door</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorModQty(int doorId, bool isAdd)
|
||||
{
|
||||
/* crea nuovo metodo per modifica singola quantità porta: DOORMODQTY */
|
||||
bool fatto = false;
|
||||
//List<ItemModel> dbResult = new List<ItemModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == doorId)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null) //if is not null edit the record found
|
||||
{
|
||||
if (isAdd)
|
||||
{
|
||||
currRec.Quantity = currRec.Quantity + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
currRec.Quantity = currRec.Quantity - 1;
|
||||
}
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorModQty: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public async Task<List<DoorOpTypeModel>> DoorOpGetDefault()
|
||||
{
|
||||
List<DoorOpTypeModel> dbResult = new List<DoorOpTypeModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetDoorOpType
|
||||
.Where(x => x.IsDefault)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorOpGetDefault: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding door's OP
|
||||
/// </summary>
|
||||
/// <param name="newOpRec">Records to add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorOpInsert(List<DoorOpModel> newOpRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetDoorOp
|
||||
.AddRange(newOpRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new DoorOpType
|
||||
/// </summary>
|
||||
/// <param name="addRec">Record to add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorOpTypeAdd(DoorOpTypeModel addRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetDoorOpType
|
||||
.Add(addRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorOpTypeAdd: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Getting door data by orderId
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AspNetRoles> GetRolesAll()
|
||||
public List<DoorModel> DoorsGetByOrderId(int orderId)
|
||||
{
|
||||
List<AspNetRoles> dbResult = new List<AspNetRoles>();
|
||||
List<DoorModel> dbResult = new List<DoorModel>();
|
||||
// retrieving data from db
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetRoles
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetRolesAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Roles methods
|
||||
|
||||
#region Order status methods
|
||||
|
||||
/// <summary>
|
||||
/// Order status
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="orderStatus"></param>
|
||||
/// <param name="dataFrom"></param>
|
||||
/// <param name="dataTo"></param>
|
||||
/// <returns></returns>
|
||||
public List<OrderStatusViewModel> GetOrderStatus(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo)
|
||||
{
|
||||
List<OrderStatusViewModel> dbResult = new List<OrderStatusViewModel>();
|
||||
using (var dbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var CompanyId = new SqlParameter("@CompanyId", companyId);
|
||||
var OrderStatus = new SqlParameter("@OrderStatus", orderStatus);
|
||||
var DataFrom = new SqlParameter("@DataFrom", dataFrom);
|
||||
var DataTo = new SqlParameter("@DataTo", dataTo);
|
||||
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetOrderStatus
|
||||
.FromSqlRaw("exec dbo.stp_OrderList_getFilt @CompanyId, @OrderStatus, @DataFrom, @DataTo", CompanyId, OrderStatus, DataFrom, DataTo)
|
||||
.DbSetDoor
|
||||
.Where(x => x.OrderId == orderId)
|
||||
.Include(o => o.OrderNav)
|
||||
.Include(t => t.TypeNav)
|
||||
.OrderBy(x => x.DoorId)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetOrderStatus:{Environment.NewLine}{exc}");
|
||||
Log.Error($"Error in DoorsGetByOrderId:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Order status methods
|
||||
/// <summary>
|
||||
/// Modifying or adding a new door
|
||||
/// </summary>
|
||||
/// <param name="addEditRec">Record to edit or add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorUpsert(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 DoorUpsert: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#region Order methods
|
||||
/// <summary>
|
||||
/// ListValues list (All)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ListValuesModel> ListValuesGetAll(string tableName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
// cerco su DB recuperando set di dati....
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetValues
|
||||
.Where(x => (x.TableName == tableName) && (x.FieldName == fieldName))
|
||||
.OrderBy(x => x.ordinal)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in ListValuesGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new order
|
||||
@@ -365,213 +477,40 @@ namespace WebDoorCreator.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Order methods
|
||||
|
||||
#region Door methods
|
||||
|
||||
/// <summary>
|
||||
/// Getting door data by orderId
|
||||
/// Order status
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="orderStatus"></param>
|
||||
/// <param name="dataFrom"></param>
|
||||
/// <param name="dataTo"></param>
|
||||
/// <returns></returns>
|
||||
public List<DoorModel> DoorsGetByOrderId(int orderId)
|
||||
public List<OrderStatusViewModel> OrderStatusGetAll(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo)
|
||||
{
|
||||
List<DoorModel> dbResult = new List<DoorModel>();
|
||||
// retrieving data from db
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
List<OrderStatusViewModel> dbResult = new List<OrderStatusViewModel>();
|
||||
using (var dbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.OrderId == orderId)
|
||||
.OrderBy(x => x.DoorId)
|
||||
var CompanyId = new SqlParameter("@CompanyId", companyId);
|
||||
var OrderStatus = new SqlParameter("@OrderStatus", orderStatus);
|
||||
var DataFrom = new SqlParameter("@DataFrom", dataFrom);
|
||||
var DataTo = new SqlParameter("@DataTo", dataTo);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetOrderStatus
|
||||
.FromSqlRaw("exec dbo.stp_OrderList_getFilt @CompanyId, @OrderStatus, @DataFrom, @DataTo", CompanyId, OrderStatus, DataFrom, DataTo)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in DoorsGetByOrderId:{Environment.NewLine}{exc}");
|
||||
Log.Error($"Error in GetOrderStatus:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new door
|
||||
/// </summary>
|
||||
/// <param name="newRec">Record to edit or add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> DoorInsert(DoorModel newRec)
|
||||
{
|
||||
int ordId = 0;
|
||||
//List<ItemModel> dbResult = new List<ItemModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == newRec.DoorId)
|
||||
.FirstOrDefault();
|
||||
// procedo solo se non c'è già
|
||||
if (currRec == null)
|
||||
{
|
||||
var newDbRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Add(newRec);
|
||||
ordId= await localDbCtx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return ordId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifying or adding a new door
|
||||
/// </summary>
|
||||
/// <param name="addEditRec">Record to edit or add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorUpsert(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 DoorUpsert: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding or removing a single door
|
||||
/// </summary>
|
||||
/// <param name="doorId">Record id to edit or add</param>
|
||||
/// <param name="isAdd">States if it has to be added or removing a door</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorModQty(int doorId, bool isAdd)
|
||||
{
|
||||
/* crea nuovo metodo per modifica singola quantità porta: DOORMODQTY */
|
||||
bool fatto = false;
|
||||
//List<ItemModel> dbResult = new List<ItemModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetDoor
|
||||
.Where(x => x.DoorId == doorId)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null) //if is not null edit the record found
|
||||
{
|
||||
if (isAdd)
|
||||
{
|
||||
currRec.Quantity = currRec.Quantity + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
currRec.Quantity = currRec.Quantity - 1;
|
||||
}
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorModQty: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Door methods
|
||||
|
||||
#region ListValues Methods
|
||||
|
||||
/// <summary>
|
||||
/// ListValues list (All)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ListValuesModel> ListValuesGetAll(string tableName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
// cerco su DB recuperando set di dati....
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetValues
|
||||
.Where(x => (x.TableName == tableName) && (x.FieldName == fieldName))
|
||||
.OrderBy(x => x.ordinal)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in ListValuesGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion ListValues Methods
|
||||
|
||||
#region Components Methods
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new Compo
|
||||
/// </summary>
|
||||
/// <param name="addRec">Record to add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CompoAdd(HardwareModel addRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetHardware
|
||||
.Add(addRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante CompoAdd: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new graphic param
|
||||
/// </summary>
|
||||
@@ -599,10 +538,35 @@ namespace WebDoorCreator.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// truncate tables
|
||||
/// Retrieving data from roles table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool TablesTruncate()
|
||||
public List<AspNetRoles> RolesGetAll()
|
||||
{
|
||||
List<AspNetRoles> dbResult = new List<AspNetRoles>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetRoles
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetRolesAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// truncate tables for testing purposes
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool TestTablesTruncate()
|
||||
{
|
||||
bool dbResult = false;
|
||||
using (var dbCtx = new WDCDataContext(_configuration))
|
||||
@@ -623,37 +587,130 @@ namespace WebDoorCreator.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Components Methods
|
||||
/// <summary>
|
||||
/// Populating DTO to handle users
|
||||
/// </summary>
|
||||
/// <param name="userId">User id to search for</param>
|
||||
/// <returns></returns>
|
||||
public List<UserRoleClaimDTO> UserRoleClaimGetByUserId()
|
||||
{
|
||||
List<UserRoleClaimDTO> dbResult = new List<UserRoleClaimDTO>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
var users = localDbCtx.DbSetUsers.ToList();
|
||||
|
||||
#region Door Operation Methods
|
||||
foreach (var item in users)
|
||||
{
|
||||
var userRoles = localDbCtx.DbSetUserRoles
|
||||
.Where(x => x.UserId == item.Id)
|
||||
.Include(u => u.UsersNav)
|
||||
.Include(u => u.RolesNav)
|
||||
.ToList();
|
||||
|
||||
//UserRoleClaimDTO userDTO = new UserRoleClaimDTO()
|
||||
//{
|
||||
// userName = item.UserName,
|
||||
// rolesName = userRoles
|
||||
//};
|
||||
//dbResult.Add(userDTO);
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a new DoorOpType
|
||||
/// Retrieving data from users table
|
||||
/// </summary>
|
||||
/// <param name="addRec">Record to add</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DoorOpTypeAdd(DoorOpTypeModel addRec)
|
||||
public List<AspNetUsers> UsersGetAll()
|
||||
{
|
||||
bool fatto = false;
|
||||
List<AspNetUsers> dbResult = new List<AspNetUsers>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetDoorOpType
|
||||
.Add(addRec);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsers
|
||||
.OrderBy(x => x.Id)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DoorOpTypeAdd: {Environment.NewLine}{exc}");
|
||||
Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Door Operation Methods
|
||||
/// <summary>
|
||||
/// Retrieving data from users table filtered by id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AspNetUsers UsersGetById(string userId)
|
||||
{
|
||||
AspNetUsers dbResult = new AspNetUsers();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
var risultato = localDbCtx
|
||||
.DbSetUsers
|
||||
.Where(x => x.Id == userId)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Id)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (risultato != null)
|
||||
{
|
||||
dbResult = risultato;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = new AspNetUsers();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetUsersById:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieving data from user/roles relation
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<UsersViewModel> UserViewGetAll()
|
||||
{
|
||||
List<UsersViewModel> dbResult = new List<UsersViewModel>();
|
||||
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// extracting entire set
|
||||
dbResult = localDbCtx
|
||||
.DbSetUsersView
|
||||
.OrderBy(x => x.UserId)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,11 @@ namespace WebDoorCreator.Data.DbModels
|
||||
/// </summary>
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica se sia da creare sempre
|
||||
/// </summary>
|
||||
public bool IsDefault { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se ci sia un hardware correlato all'operazione
|
||||
/// </summary>
|
||||
|
||||
+713
@@ -0,0 +1,713 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebDoorCreator.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebDoorCreator.Data.Migrations.WDCData
|
||||
{
|
||||
[DbContext(typeof(WDCDataContext))]
|
||||
[Migration("20230330111904_DoorOpTypeinit")]
|
||||
partial class DoorOpTypeinit
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseCollation("Latin1_General_CI_AS")
|
||||
.HasAnnotation("ProductVersion", "6.0.14")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations());
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations());
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("datetimeoffset");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations());
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b =>
|
||||
{
|
||||
b.Property<int>("CompanyId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CompanyId"), 1L, 1);
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)");
|
||||
|
||||
b.Property<string>("City")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("CompanyExtCode")
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)");
|
||||
|
||||
b.Property<string>("CompanyName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)");
|
||||
|
||||
b.Property<string>("CompanyToken")
|
||||
.IsRequired()
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<string>("PrivateNote")
|
||||
.IsRequired()
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("VAT")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("ZipCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CompanyId");
|
||||
|
||||
b.ToTable("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b =>
|
||||
{
|
||||
b.Property<int>("DoorId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorId"), 1L, 1);
|
||||
|
||||
b.Property<DateTime>("DateIns")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateLockExpiry")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateMod")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("DoorDescript")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("DoorExtCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MeasureUnit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TypeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("UnitCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("UserIdIns")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdLock")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdMod")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("DoorId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("TypeId");
|
||||
|
||||
b.ToTable("Door");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b =>
|
||||
{
|
||||
b.Property<int>("DoorOpId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorOpId"), 1L, 1);
|
||||
|
||||
b.Property<DateTime>("DateIns")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateMod")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("DoorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DoorOpTypId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("JsoncConfigVal")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdIns")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdMod")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("DoorOpId");
|
||||
|
||||
b.HasIndex("DoorId");
|
||||
|
||||
b.HasIndex("DoorOpTypId");
|
||||
|
||||
b.ToTable("DoorOp");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b =>
|
||||
{
|
||||
b.Property<int>("DoorOpTypId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorOpTypId"), 1L, 1);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<HierarchyId>("DoorOpIdPathFromPatriarch")
|
||||
.HasColumnType("hierarchyid");
|
||||
|
||||
b.Property<string>("ExtDescript")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ExtOpCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FPath")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("HasHw")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("HwCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("HwDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("IsConcrete")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("Isdefault")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("JsoncConfig")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OpCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Rev")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("ValidFrom")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("ValidUntil")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("DoorOpTypId");
|
||||
|
||||
b.ToTable("DoorOpType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b =>
|
||||
{
|
||||
b.Property<int>("TypeId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TypeId"), 1L, 1);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("TypeCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("TypeId");
|
||||
|
||||
b.ToTable("DoorType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b =>
|
||||
{
|
||||
b.Property<int>("GraphicParamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("GraphicParamId"), 1L, 1);
|
||||
|
||||
b.Property<int>("compoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("graphicParamAlias")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("graphicParamDefaultVal")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("graphicParamKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("graphicParamName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("graphicParamType")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("graphicParamsN")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("GraphicParamId");
|
||||
|
||||
b.ToTable("GraphicParams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b =>
|
||||
{
|
||||
b.Property<int>("HardwareId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("HardwareId"), 1L, 1);
|
||||
|
||||
b.Property<string>("compoAlias")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("compoLayerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("compoName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("compoTemplateIsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.HasKey("HardwareId");
|
||||
|
||||
b.ToTable("Hardware");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b =>
|
||||
{
|
||||
b.Property<string>("TableName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("FieldName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("value")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("label")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("ordinal")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("TableName", "FieldName", "value");
|
||||
|
||||
b.ToTable("ListValues");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
TableName = "Opening",
|
||||
FieldName = "Swing",
|
||||
value = "LH",
|
||||
label = "Left Handed",
|
||||
ordinal = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Opening",
|
||||
FieldName = "Swing",
|
||||
value = "RH",
|
||||
label = "Right Handed",
|
||||
ordinal = 2
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Opening",
|
||||
FieldName = "Swing",
|
||||
value = "LHR",
|
||||
label = "Left Handed Reverse",
|
||||
ordinal = 3
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Opening",
|
||||
FieldName = "Swing",
|
||||
value = "RHR",
|
||||
label = "Right Handed Reverse",
|
||||
ordinal = 4
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Edges",
|
||||
FieldName = "EdgeType",
|
||||
value = "BV",
|
||||
label = "Bevel",
|
||||
ordinal = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Edges",
|
||||
FieldName = "EdgeType",
|
||||
value = "SQ",
|
||||
label = "Squared",
|
||||
ordinal = 2
|
||||
},
|
||||
new
|
||||
{
|
||||
TableName = "Edges",
|
||||
FieldName = "EdgeType",
|
||||
value = "1B",
|
||||
label = "Bull Nose 1",
|
||||
ordinal = 3
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b =>
|
||||
{
|
||||
b.Property<int>("OrderId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrderId"), 1L, 1);
|
||||
|
||||
b.Property<int>("CompanyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateIns")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateMod")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("OrderDescript")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderExtCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UserIdIns")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdMod")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("OrderId");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b =>
|
||||
{
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrderId"), 1L, 1);
|
||||
|
||||
b.Property<int>("CompanyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateIns")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("NumDoors")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("NumType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("OrderDescript")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("OrderExtCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("OrderStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("TotCost")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("UserIdIns")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserIdMod")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("OrderId");
|
||||
|
||||
b.ToView("OrderStatusViewModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("RoleName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.ToView("UsersViewModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b =>
|
||||
{
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RolesNav");
|
||||
|
||||
b.Navigation("UsersNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b =>
|
||||
{
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("TypeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("OrderNav");
|
||||
|
||||
b.Navigation("TypeNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b =>
|
||||
{
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("DoorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("DoorOpTypId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("DoorNav");
|
||||
|
||||
b.Navigation("DoorOpTypeNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b =>
|
||||
{
|
||||
b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CompanyNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebDoorCreator.Data.Migrations.WDCData
|
||||
{
|
||||
public partial class DoorOpTypeinit : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDefault",
|
||||
table: "DoorOpType",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDefault",
|
||||
table: "DoorOpType");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,6 +325,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData
|
||||
b.Property<bool>("IsConcrete")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("Isdefault")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("JsoncConfig")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace WebDoorCreator.UI.Components.Buttons
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public int doorId { get; set; } = 0;
|
||||
public int DoorId { get; set; } = 0;
|
||||
[Parameter]
|
||||
public int OrderId { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public bool isAdd { get; set; }
|
||||
@@ -31,7 +33,7 @@ namespace WebDoorCreator.UI.Components.Buttons
|
||||
{
|
||||
//var door = new DoorModel();
|
||||
doorChange = false;
|
||||
var done = await WDService.DoorModQty(doorId, isAdd);
|
||||
var done = await WDService.DoorModQty(OrderId, DoorId, isAdd);
|
||||
if (done)
|
||||
{
|
||||
doorChange = true;
|
||||
|
||||
@@ -3,25 +3,45 @@
|
||||
<table class="table table-sm table-striped table-responsive-md border border-dark">
|
||||
<thead>
|
||||
<tr class="bg-dark text-light">
|
||||
<td>Door Type</td>
|
||||
<th></th>
|
||||
<th>Door Type</th>
|
||||
<th>Description</th>
|
||||
<th>Door external code</th>
|
||||
<th>Doors Number</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th class="text-end"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var door in DoorsList)
|
||||
{
|
||||
<tr>
|
||||
<td>@door.TypeId</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-warning" @onclick="()=> editRec(door.DoorId)"><i class="fa-solid fa-pen-to-square"></i></button>
|
||||
</td>
|
||||
<td>@(door.TypeNav?.Description ?? "-")</td>
|
||||
<td>@door.DoorDescript</td>
|
||||
<td>@door.DoorExtCode</td>
|
||||
<td>@door.Quantity</td>
|
||||
<td>
|
||||
<ButtonAddRemDoor E_isChange="catchDoorChange" doorId="@door.DoorId" isAdd="false"></ButtonAddRemDoor>
|
||||
@if (door.Quantity > 1)
|
||||
{
|
||||
<ButtonAddRemDoor E_isChange="catchDoorChange" OrderId="@door.OrderId" DoorId="@door.DoorId" isAdd="false"></ButtonAddRemDoor>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary disabled"><i class="fa-solid fa-minus"></i> <i class="fa-solid fa-1"></i></button>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<ButtonAddRemDoor E_isChange="catchDoorChange" doorId="@door.DoorId" isAdd="true"></ButtonAddRemDoor>
|
||||
<ButtonAddRemDoor E_isChange="catchDoorChange" OrderId="@door.OrderId" DoorId="@door.DoorId" isAdd="true"></ButtonAddRemDoor>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@if (door.OrderNav?.Status < Core.Enum.OrderStatus.Sent)
|
||||
{
|
||||
<button class="btn btn-sm btn-danger" @onclick="() => deleteRecord(door)"><i class="fa-solid fa-trash-can"></i></button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.JSInterop;
|
||||
using WebDoorCreator.Data.DbModels;
|
||||
using WebDoorCreator.UI.Data;
|
||||
@@ -8,14 +7,7 @@ namespace WebDoorCreator.UI.Components.DoorMan
|
||||
{
|
||||
public partial class DoorList
|
||||
{
|
||||
[Inject]
|
||||
protected WebDoorCreatorService WDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int currOrderId { get; set; } = 0;
|
||||
@@ -23,19 +15,26 @@ namespace WebDoorCreator.UI.Components.DoorMan
|
||||
[Parameter]
|
||||
public EventCallback<bool> E_DoorChanged { get; set; }
|
||||
|
||||
protected bool IsChanged { get; set; } = false;
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected List<DoorModel>? DoorsList { get; set; } = null;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
protected bool IsChanged { get; set; } = false;
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
DoorsList = await WDService.DoorsGetByOrderId(currOrderId);
|
||||
}
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected WebDoorCreatorService WDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task catchDoorChange(bool isChanged)
|
||||
{
|
||||
@@ -47,5 +46,33 @@ namespace WebDoorCreator.UI.Components.DoorMan
|
||||
}
|
||||
await E_DoorChanged.InvokeAsync(isChanged);
|
||||
}
|
||||
|
||||
protected async Task deleteRecord(DoorModel currRec)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Door Deletion requested: are you sure to remove {currRec.DoorDescript}?"))
|
||||
return;
|
||||
|
||||
await WDService.DoorDelete(currRec);
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task editRec(int doorId)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
NavManager.NavigateTo($"/DoorDefinition?idOrd={currOrderId}&idDoor={doorId}");
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
DoorsList = await WDService.DoorGetByOrderId(currOrderId);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace WebDoorCreator.UI.Components.Order
|
||||
await Task.Delay(1);
|
||||
if (userClaims != null)
|
||||
{
|
||||
ListOrdersStatus = await WDService.GetOrderStatus(userCurrCompany, 0, domani.AddYears(-2), domani);
|
||||
ListOrdersStatus = await WDService.OrderStatusGetFilt(userCurrCompany, 0, domani.AddYears(-2), domani);
|
||||
}
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
@@ -120,10 +120,10 @@ namespace WebDoorCreator.UI.Components.Order
|
||||
}
|
||||
|
||||
protected async Task deleteRecord(OrderStatusViewModel currRec)
|
||||
{
|
||||
{
|
||||
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Order Deletion requested: are you sure to remove {currRec.OrderExtCode}?"))
|
||||
return;
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Order Deletion requested: are you sure to remove {currRec.OrderExtCode}?"))
|
||||
return;
|
||||
|
||||
await Task.Delay(1);
|
||||
var done = await WDService.OrderRem(currRec.OrderId);
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace WebDoorCreator.UI.Components.Users
|
||||
{
|
||||
//ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
UsersList = await WDService.GetUserView();
|
||||
RolesList = await WDService.GetRolesAll();
|
||||
UsersList = await WDService.UserViewGetAll();
|
||||
RolesList = await WDService.RolesGetAll();
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace WebDoorCreator.UI.Components.Users
|
||||
private async Task setCurrUser(string userId)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
currUser = await WDService.GetUsersById(userId);
|
||||
currUser = await WDService.UsersGetById(userId);
|
||||
}
|
||||
|
||||
//private async Task editRec(CompanyModel currComp)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,7 @@ namespace WebDoorCreator.UI.Pages
|
||||
var domani = DateTime.Today.AddDays(1);
|
||||
ListOrdersStatus = null;
|
||||
await Task.Delay(1);
|
||||
ListOrdersStatus = await WDService.GetOrderStatus(0, 0, domani.AddYears(-2), domani);
|
||||
ListOrdersStatus = await WDService.OrderStatusGetFilt(0, 0, domani.AddYears(-2), domani);
|
||||
if (ListOrdersStatus != null)
|
||||
{
|
||||
orderStatus = ListOrdersStatus.Where(x => x.OrderId == idOrd).FirstOrDefault();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace WebDoorCreator.UI.Pages
|
||||
|
||||
protected List<DoorModel>? DoorsList { get; set; } = null;
|
||||
|
||||
protected int idOrd { get; set; } = 0;
|
||||
protected int idOrd { get; set; } = -1;
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
@@ -60,8 +60,8 @@ namespace WebDoorCreator.UI.Pages
|
||||
protected async Task createDoor()
|
||||
{
|
||||
// conto le porte x questo ordine e uso x chiamata successiva...
|
||||
var door4ord = await WDService.DoorsGetByOrderId(idOrd);
|
||||
int numDoors = door4ord?.Count ?? 0;
|
||||
var door4ord = await WDService.DoorGetByOrderId(idOrd);
|
||||
int numDoors = door4ord?.Count + 1 ?? 1;
|
||||
DateTime adesso = DateTime.Now;
|
||||
// creo una nuova porta...
|
||||
DoorModel newDoor = new DoorModel()
|
||||
@@ -74,7 +74,7 @@ namespace WebDoorCreator.UI.Pages
|
||||
DateIns = adesso,
|
||||
DateMod = adesso,
|
||||
DateLockExpiry = adesso.AddHours(1),
|
||||
DoorDescript = $"ORD {idOrd} | Door {numDoors + 1:00}",
|
||||
DoorDescript = $"ORD {idOrd} | Door {numDoors:00}",
|
||||
DoorExtCode = $"ORD {idOrd} | Ext Code --",
|
||||
Quantity = 1,
|
||||
UnitCost = 0,
|
||||
@@ -82,6 +82,23 @@ namespace WebDoorCreator.UI.Pages
|
||||
};
|
||||
// chiamo metodo x insert...
|
||||
var doorId = await WDService.DoorInsert(newDoor);
|
||||
// aggiungo le lavorazioni standard...
|
||||
var doorOpList = await WDService.DoorOpGetDefault();
|
||||
|
||||
List<DoorOpModel> listOp = doorOpList
|
||||
.Select(x => new DoorOpModel()
|
||||
{
|
||||
DateIns = adesso,
|
||||
DateMod = adesso,
|
||||
UserIdIns = WDCUService.newUserName,
|
||||
UserIdMod = WDCUService.newUserName,
|
||||
DoorOpTypId = x.DoorOpTypId,
|
||||
DoorId = doorId,
|
||||
JsoncConfigVal = x.JsoncConfig
|
||||
})
|
||||
.ToList();
|
||||
// salvo Door OP associate
|
||||
await WDService.DoorOpInsert(doorId, listOp);
|
||||
|
||||
// rimando alla pagina... dettaglio...
|
||||
NavManager.NavigateTo($"/DoorDefinition?idOrd={idOrd}&idDoor={doorId}");
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace WebDoorCreator.UI.Pages
|
||||
protected int userCurrCompany { get; set; }
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
DoorsList = await WDService.DoorsGetByOrderId(currOrderId);
|
||||
DoorsList = await WDService.DoorGetByOrderId(currOrderId);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace WebDoorCreator.UI.Pages
|
||||
protected async Task refreshHw()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
await WDService.SetAllCompoList(@$"{defaultPath}");
|
||||
await WDService.CompoListSetAll(@$"{defaultPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user