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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user