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