static public async Task <string> Save(ECompanyWorkTimes eWorkTime) { try { using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eWorkTime.id)) { eWorkTime.id = Guid.NewGuid().ToString(); var e = await context.CompanyWorkTimes.AddAsync(eWorkTime); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.CompanyWorkTimes.Update(eWorkTime); await context.SaveChangesAsync(); return(e.Entity.id); } } catch (DbUpdateException e) { Console.WriteLine(e.ToString()); throw; } }
static public async Task <string> Save(ECompany eCompany) { if (eCompany.eCompanyConfig != null) { eCompany.config = JsonConvert.SerializeObject(eCompany.eCompanyConfig, Formatting.Indented); } using var context = new SMySQLContext(); eCompany.modificationDateUTC = DateTime.UtcNow; if (string.IsNullOrEmpty(eCompany.id)) { eCompany.id = Guid.NewGuid().ToString(); eCompany.creationDateUTC = DateTime.UtcNow; var e = await context.Companies.AddAsync(eCompany); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.Companies.Update(eCompany); await context.SaveChangesAsync(); return(e.Entity.id); } }
static public ECompanyWorkTimes GetByCompanyID(string companyID) { using var context = new SMySQLContext(); ECompanyWorkTimes eCompanyWorkTimes = context.CompanyWorkTimes.SingleOrDefault(x => x.companyID == companyID); return(eCompanyWorkTimes); }
static public ECompany GetByLabSite(string labSite) { using var context = new SMySQLContext(); ECompany eCompany = context.Companies.SingleOrDefault(x => labSite.ToLower().Contains(x.labSite)); return(eCompany); }
static public ECompany GetByID(string id) { using (var context = new SMySQLContext()) { ECompany eCompany = context.Companies.SingleOrDefault(x => x.id == id); return(eCompany); } }
public EUser Authenticate2(EUser e) { using var context = new SMySQLContext(); var eUser = context.Users.FirstOrDefault(x => x.Email == e.Email && x.Password == e.Password); return(eUser); }
static public ECompanyProposal GetByID(string id) { using (var context = new SMySQLContext()) { ECompanyProposal eCompanyProposal = context.CompanyProposals.SingleOrDefault(x => x.id == id); return(eCompanyProposal); } }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(ELogisticsDriverIncident eIncident) { try { eIncident.modificationDateUTC = DateTime.UtcNow; using (var context = new SMySQLContext()) { if (string.IsNullOrEmpty(eIncident.id)) { eIncident.id = Guid.NewGuid().ToString(); eIncident.creationDateUTC = eIncident.modificationDateUTC = DateTime.UtcNow; var e = await context.LogisticsDriverIncidents.AddAsync(eIncident); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.LogisticsDriverIncidents.Update(eIncident); await context.SaveChangesAsync(); return(e.Entity.id); } } } catch (DbUpdateException e) { Console.WriteLine(e.ToString()); throw; } }
public ECompanyAdminUser GetByID(string id) { using var context = new SMySQLContext(); var e = context.CompanyAdminUsers.SingleOrDefault(x => x.Id == id); return(e); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EDeliveryOrder eOrder) { try { eOrder.modificationDateUTC = DateTime.UtcNow; using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eOrder.id)) { eOrder.id = Guid.NewGuid().ToString(); eOrder.creationDateUTC = eOrder.modificationDateUTC = DateTime.UtcNow; var e = await context.DeliveryOrders.AddAsync(eOrder); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.DeliveryOrders.Update(eOrder); await context.SaveChangesAsync(); return(e.Entity.id); } } catch (DbUpdateException e) { Console.WriteLine(e.ToString()); throw; } }
public ESearch GetByID(string id) { using var context = new SMySQLContext(); ESearch e = context.Searches.SingleOrDefault(x => x.Id == id); return(e); }
static public bool ConfirmOrder(EDeliveryConfirmOrder eDeliveryConfirmOrder) { try { using var context = new SMySQLContext(); EDeliveryOrder e = new EDeliveryOrder(); e.companyID = eDeliveryConfirmOrder.companyID; e.visualID = GetNextVisualID(e.companyID); e.entityID = eDeliveryConfirmOrder.userID; e.paymentMethodType = eDeliveryConfirmOrder.paymentMethodType; e.total = eDeliveryConfirmOrder.total; e.creationDateUTC = e.modificationDateUTC = DateTime.UtcNow; if (eDeliveryConfirmOrder.creationDateLocal == null) { e.creationDateLocal = DateTime.UtcNow; } else { e.creationDateLocal = eDeliveryConfirmOrder.creationDateLocal; } e.notes = eDeliveryConfirmOrder.comments; e.status = DeliveryStatus.PendingApproval; e.content = JsonConvert.SerializeObject(eDeliveryConfirmOrder.productList); e.changeFor = eDeliveryConfirmOrder.changeFor; var result = context.DeliveryOrders.Add(e); context.SaveChanges(); return(true); } catch (Exception e) { SLogger.LogError(e); } return(false); }
static public EBaseEntity GetByID(string id) { using var context = new SMySQLContext(); EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.id == id); return(eBaseEntity); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EBaseEntity eBaseEntity) { eBaseEntity.modificationDateUTC = DateTime.UtcNow; eBaseEntity.type = EntityType.Supplier; using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eBaseEntity.id)) { eBaseEntity.id = Guid.NewGuid().ToString(); eBaseEntity.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } else { var e = context.BaseUsers.Update(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList); return(eBaseEntity.id); }
static public List <EDeliveryProductAddon> GetAllGroupNames(string companyID) { using var context = new SMySQLContext(); List <EDeliveryProductAddon> list = context.DeliveryProductAddons.Where(x => x.companyID == companyID && x.parentID == null).OrderBy("name asc").ToList(); return(list); }
static public EBaseAddress GetByID(string id) { using (var context = new SMySQLContext()) { EBaseAddress eBaseAddress = context.BaseAddresses.SingleOrDefault(x => x.id == id); return(eBaseAddress); } }
public EProduct GetByID(string id) { using var context = new SMySQLContext(); var e = context.Products.SingleOrDefault(x => x.Id == id); return(e); }
static public ELogisticsDriverIncident GetByID(string id) { using var context = new SMySQLContext(); ELogisticsDriverIncident eIncident = context.LogisticsDriverIncidents.SingleOrDefault(x => x.id == id); return(eIncident); }
public EUser GetByID(Int64 id) { using var context = new SMySQLContext(); var e = context.Users.SingleOrDefault(x => x.Id == id); return(e); }
static public EFile GetCompanyLogo(string companyID) { using var context = new SMySQLContext(); EFile eFile = context.Files.SingleOrDefault(x => x.companyID == companyID); return(eFile); }
static public EDeliveryProductAddon GetByID(string id) { using var context = new SMySQLContext(); EDeliveryProductAddon eAddon = context.DeliveryProductAddons.SingleOrDefault(x => x.id == id); return(eAddon); }
static public List <EDeliveryProductAddon> GetChildAddons(string parentGroupID) { using var context = new SMySQLContext(); List <EDeliveryProductAddon> list = context.DeliveryProductAddons.Where(x => x.parentID == parentGroupID).OrderBy("name asc").ToList(); return(list); }
static public EBaseEntity GetByID(string id) { using (var context = new SMySQLContext()) { EBaseEntity eDriver = context.LogisticsDrivers.SingleOrDefault(x => x.id == id); return(eDriver); } }
static public bool SaveClientAddresses(string entityID, List <EBaseAddress> addressList) { try { if (!addressList.Any()) { return(true); } using var context = new SMySQLContext(); foreach (EBaseAddress eAddress in addressList) { eAddress.modificationDateUTC = DateTime.UtcNow; eAddress.entityID = entityID; if (string.IsNullOrEmpty(eAddress.id)) { eAddress.id = Guid.NewGuid().ToString(); eAddress.creationDateUTC = DateTime.UtcNow; var e = context.BaseAddresses.Add(eAddress); context.SaveChanges(); //return e.Entity.id; } else { var e = context.BaseAddresses.Update(eAddress); context.SaveChanges(); //return e.Entity.id; } } return(true); } catch (DbUpdateException e) { Debug.WriteLine(e.InnerException.ToString()); return(false); } }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EBaseEntity eDriver) { eDriver.modificationDateUTC = DateTime.UtcNow; eDriver.type = EntityType.Driver; using (var context = new SMySQLContext()) { if (string.IsNullOrEmpty(eDriver.id)) { eDriver.id = Guid.NewGuid().ToString(); eDriver.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eDriver); await context.SaveChangesAsync(); return(e.Entity.id); } else { // ELogisticsDriver oldDriver = context.LogisticsDrivers.SingleOrDefault(x => x.id == eDriver.id); // eDriver.password = eDriver.password; var e = context.BaseUsers.Update(eDriver); await context.SaveChangesAsync(); return(e.Entity.id); } } }
static public List <EDeliveryProductOption> GetAll(string companyID, int listCount = -1, int pageNumber = 0, string orderBy = "name asc") { using var context = new SMySQLContext(); List <EDeliveryProductOption> list = null; if (listCount == -1) { list = context.DeliveryProductOptions.Where(x => x.companyID == companyID).OrderBy(orderBy).ToList(); } else { list = context.DeliveryProductOptions.Where(x => x.companyID == companyID).OrderBy(orderBy).Skip(pageNumber * listCount).Take(listCount).ToList(); } foreach (var option in list) { if (string.IsNullOrEmpty(option.parentID)) { continue; } var eGroup = GetByID(option.parentID); if (string.IsNullOrEmpty(eGroup.internalName)) { option.completeParentGroupName = eGroup.name; } else { option.completeParentGroupName = eGroup.internalName; } option.parentGroupName = eGroup.name; } list = list.OrderBy(x => x.parentID).ToList(); return(list); }
static public async Task <EDeliveryProductCategory> GetByID(string id) { using (var context = new SMySQLContext()) { EDeliveryProductCategory eCategory = await context.DeliveryProductCategories.SingleOrDefaultAsync(x => x.id == id); return(eCategory); } }
public IActionResult GetByID(string id) { using (var context = new SMySQLContext()) { ECompanyAdminUser e = context.CompanyUsers.FirstOrDefault <ECompanyAdminUser>(x => x.id == id); e.password = ""; return(Ok(e)); } }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { using var context = new SMySQLContext(); users = context.Users.ToList(); StateHasChanged(); } }
static public Int64 GetNextVisualID(string companyID) { using var context = new SMySQLContext(); var eDeliveryOrder = context.DeliveryOrders.Where(x => x.companyID == companyID) .OrderByDescending(t => t.visualID) .FirstOrDefault(); return(eDeliveryOrder.visualID + 1); }