static public EDeliveryProductAddon GetByID(string id) { using var context = new SMySQLContext(); EDeliveryProductAddon eAddon = context.DeliveryProductAddons.SingleOrDefault(x => x.id == id); return(eAddon); }
static public async Task <bool> Remove(string id) { using var context = new SMySQLContext(); EDeliveryProductAddon eAddon = context.DeliveryProductAddons.SingleOrDefault(x => x.id == id); if (eAddon == null) { return(false); } context.Remove(eAddon); await context.SaveChangesAsync(); return(true); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EDeliveryProductAddon eAddon) { using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eAddon.id)) { eAddon.id = Guid.NewGuid().ToString(); var e = await context.DeliveryProductAddons.AddAsync(eAddon); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.DeliveryProductAddons.Update(eAddon); await context.SaveChangesAsync(); return(e.Entity.id); } }
public async Task <IActionResult> Save([FromBody] EDeliveryProductAddon eAddon) { string id = await SDeliveryProductsAddons.Save(eAddon); return(Ok(id)); }
public IActionResult GetByID(string id) { EDeliveryProductAddon eAddon = SDeliveryProductsAddons.GetByID(id); return(Ok(eAddon)); }