static public ECompanyBillToPay GetByID(string id) { using (var context = new SMySQLContext()) { ECompanyBillToPay eBillToPay = context.CompanyBillsToPay.SingleOrDefault(x => x.id == id); return(eBillToPay); } }
public IActionResult GetByID(string id) { ECompanyBillToPay eBillToPay = SCompaniesBillsToPay.GetByID(id); return(Ok(eBillToPay)); // SCompaniesSuppliersService sSuppliersService = SDefines.ApplicationContainer.Resolve<SCompaniesSuppliersService>(); // //eBillToPay.nomeFornecedor = sFornecedores.GetByID(eBillToPay.fornecedorID).nomeFantasia; }
static public async Task <bool> Remove(string id) { using (var context = new SMySQLContext()) { ECompanyBillToPay eBillToPay = context.CompanyBillsToPay.SingleOrDefault(x => x.id == id); if (eBillToPay == null) { return(false); } context.Remove(eBillToPay); await context.SaveChangesAsync(); return(true); } }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(ECompanyBillToPay eBillToPay) { eBillToPay.modificationDateUTC = DateTime.UtcNow; using (var context = new SMySQLContext()) { if (string.IsNullOrEmpty(eBillToPay.id)) { eBillToPay.id = Guid.NewGuid().ToString(); eBillToPay.creationDateUTC = DateTime.UtcNow; var e = await context.CompanyBillsToPay.AddAsync(eBillToPay); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.CompanyBillsToPay.Update(eBillToPay); await context.SaveChangesAsync(); return(e.Entity.id); } } }
public async Task <IActionResult> Save([FromBody] ECompanyBillToPay eBillToPay) { var result = await SCompaniesBillsToPay.Save(eBillToPay); return(Ok(result)); }