OrdersHomePage:

- Ok nuova gestione modale
- ok crea nuovo
- ok btn add se selezionata company
... test clona NON ancora OK
This commit is contained in:
Samuele Locatelli
2023-05-31 19:28:56 +02:00
parent 83dd3bb553
commit dd30d2cbf6
18 changed files with 364 additions and 176 deletions
@@ -21,59 +21,6 @@ namespace WebDoorCreator.Data.Controllers
#region Public Methods
/// <summary>
/// Adding a new User
/// </summary>
/// <param name="addEditRec">Record to edit or add</param>
/// <returns></returns>
public async Task<bool> UserAddMod(AspNetUsers addEditRec)
{
bool fatto = false;
//List<ItemModel> dbResult = new List<ItemModel>();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
var currRec = localDbCtx
.DbSetUsers
.Where(x => x.Id == addEditRec.Id)
.FirstOrDefault();
//if is not null edit the record found
if (currRec != null)
{
currRec.Id = addEditRec.Id;
currRec.UserName = addEditRec.UserName;
currRec.NormalizedUserName = addEditRec.NormalizedUserName;
currRec.Email = addEditRec.Email;
currRec.EmailConfirmed = addEditRec.EmailConfirmed;
currRec.LockoutEnabled = addEditRec.LockoutEnabled;
currRec.LockoutEnd = addEditRec.LockoutEnd;
currRec.ConcurrencyStamp = addEditRec.ConcurrencyStamp;
currRec.SecurityStamp = addEditRec.SecurityStamp;
currRec.AccessFailedCount = addEditRec.AccessFailedCount;
currRec.PhoneNumberConfirmed = addEditRec.PhoneNumberConfirmed;
currRec.PhoneNumber = addEditRec.PhoneNumber;
currRec.TwoFactorEnabled = addEditRec.TwoFactorEnabled;
localDbCtx.Entry(currRec).State = EntityState.Modified;
}
//if is null add the record as new in the table
else
{
localDbCtx
.DbSetUsers
.Add(addEditRec);
}
await localDbCtx.SaveChangesAsync();
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante CompanyAddMod: {Environment.NewLine}{exc}");
}
}
return fatto;
}
/// <summary>
/// Adding a new company
/// </summary>
@@ -820,10 +767,10 @@ namespace WebDoorCreator.Data.Controllers
/// Adding a new order
/// </summary>
/// <param name="addRec">Record to add</param>
/// <returns></returns>
public async Task<bool> OrderAdd(OrderModel addRec)
/// <returns>OrderId</returns>
public async Task<int> OrderAdd(OrderModel addRec)
{
bool fatto = false;
int newOrdId = 0;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
@@ -832,13 +779,47 @@ namespace WebDoorCreator.Data.Controllers
.DbSetOrders
.Add(addRec);
await localDbCtx.SaveChangesAsync();
fatto = true;
newOrdId = addRec.OrderId;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante OrderAdd: {Environment.NewLine}{exc}");
}
}
return newOrdId;
}
/// <summary>
/// Duplicazione di un ordine da SRC a DEST (Doors + DoorOp)
/// </summary>
/// <param name="OrdIdSrc"></param>
/// <param name="OrdIdDest"></param>
/// <param name="UsrIdMod"></param>
/// <returns></returns>
public async Task<bool> OrderDuplicate(int OrdIdSrc, int OrdIdDest, string UsrIdMod)
{
await Task.Delay(1);
bool fatto = false;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
var OrderIdSrc = new SqlParameter("@OrderIdSrc", OrdIdSrc);
var OrderIdDest = new SqlParameter("@OrderIdDest", OrdIdDest);
var UserIdMod = new SqlParameter("@UserIdMod", UsrIdMod);
// stored di cloning dati ordine
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_OrderClone @OrderIdSrc, @OrdIdDest, @UserIdMod", OrderIdSrc, OrderIdDest, UserIdMod);
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante OrderDuplicate:{Environment.NewLine}{exc}");
}
}
return fatto;
}
@@ -1095,6 +1076,59 @@ namespace WebDoorCreator.Data.Controllers
return dbResult;
}
/// <summary>
/// Adding a new User
/// </summary>
/// <param name="addEditRec">Record to edit or add</param>
/// <returns></returns>
public async Task<bool> UserAddMod(AspNetUsers addEditRec)
{
bool fatto = false;
//List<ItemModel> dbResult = new List<ItemModel>();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
var currRec = localDbCtx
.DbSetUsers
.Where(x => x.Id == addEditRec.Id)
.FirstOrDefault();
//if is not null edit the record found
if (currRec != null)
{
currRec.Id = addEditRec.Id;
currRec.UserName = addEditRec.UserName;
currRec.NormalizedUserName = addEditRec.NormalizedUserName;
currRec.Email = addEditRec.Email;
currRec.EmailConfirmed = addEditRec.EmailConfirmed;
currRec.LockoutEnabled = addEditRec.LockoutEnabled;
currRec.LockoutEnd = addEditRec.LockoutEnd;
currRec.ConcurrencyStamp = addEditRec.ConcurrencyStamp;
currRec.SecurityStamp = addEditRec.SecurityStamp;
currRec.AccessFailedCount = addEditRec.AccessFailedCount;
currRec.PhoneNumberConfirmed = addEditRec.PhoneNumberConfirmed;
currRec.PhoneNumber = addEditRec.PhoneNumber;
currRec.TwoFactorEnabled = addEditRec.TwoFactorEnabled;
localDbCtx.Entry(currRec).State = EntityState.Modified;
}
//if is null add the record as new in the table
else
{
localDbCtx
.DbSetUsers
.Add(addEditRec);
}
await localDbCtx.SaveChangesAsync();
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante CompanyAddMod: {Environment.NewLine}{exc}");
}
}
return fatto;
}
/// <summary>
/// Populating DTO to handle users
/// </summary>
@@ -1241,6 +1275,69 @@ namespace WebDoorCreator.Data.Controllers
}
return DTOResult;
}
/// <summary>
/// Aggiunta di un nuovo set di lemmi
/// </summary>
/// <returns></returns>
public async Task<bool> VocLemmaInsert()
{
await Task.Delay(1);
bool fatto = false;
//var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
//bool isOk = await VocLemmaInsertPrepare(listNewTerms);
// stored di merge dati in vocabolario
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Import");
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaInsert: {Environment.NewLine}{exc}");
}
}
return fatto;
}
public async Task<bool> VocLemmaInsertPrepare(List<VocabularyTempModel> listNewTerms)
{
bool fatto = false;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
// stored di reset vocabolario
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Prepare");
await localDbCtx.SaveChangesAsync();
// import massivo dati in tab temp
localDbCtx
.DbSetVocabularyTemp
.AddRange(listNewTerms);
await localDbCtx.SaveChangesAsync();
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaInsertPrepare: {Environment.NewLine}{exc}");
}
}
return fatto;
}
public Dictionary<string, Dictionary<string, string>> VocLemmaTEMPGetAll()
{
Dictionary<string, Dictionary<string, string>> DTOResult = new Dictionary<string, Dictionary<string, string>>();
@@ -1277,68 +1374,6 @@ namespace WebDoorCreator.Data.Controllers
}
return DTOResult;
}
public async Task<bool> VocLemmaInsertPrepare(List<VocabularyTempModel> listNewTerms)
{
bool fatto = false;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
// stored di reset vocabolario
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Prepare");
await localDbCtx.SaveChangesAsync();
// import massivo dati in tab temp
localDbCtx
.DbSetVocabularyTemp
.AddRange(listNewTerms);
await localDbCtx.SaveChangesAsync();
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaInsertPrepare: {Environment.NewLine}{exc}");
}
}
return fatto;
}
/// <summary>
/// Aggiunta di un nuovo set di lemmi
/// </summary>
/// <param name="listNewTerms"></param>
/// <returns></returns>
public async Task<bool> VocLemmaInsert()
{
await Task.Delay(1);
bool fatto = false;
//var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
//bool isOk = await VocLemmaInsertPrepare(listNewTerms);
// stored di merge dati in vocabolario
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Import");
fatto = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaInsert: {Environment.NewLine}{exc}");
}
}
return fatto;
}
#endregion Public Methods