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 ECompanyWorkTimes GetByCompanyID(string companyID) { using var context = new SMySQLContext(); ECompanyWorkTimes eCompanyWorkTimes = context.CompanyWorkTimes.SingleOrDefault(x => x.companyID == companyID); return(eCompanyWorkTimes); }
public async Task <IActionResult> Save([FromBody] ECompanyWorkTimes eWorkTimes) { var result = await SCompaniesWorkTime.Save(eWorkTimes); return(Ok(result)); }
public IActionResult GetByCompanyID(string id) { ECompanyWorkTimes result = SCompaniesWorkTime.GetByCompanyID(id); return(Ok(result)); }