static public async Task <EDeliveryProduct> GetByID(string id) { using var context = new SMySQLContext(); EDeliveryProduct eDeliveryProduct = await context.DeliveryProducts.SingleOrDefaultAsync(x => x.id == id); if (!string.IsNullOrEmpty(eDeliveryProduct.option1ParentGroupID)) { eDeliveryProduct.option1ParentGroupName = SDeliveryProductsOptions.GetByID(eDeliveryProduct.option1ParentGroupID).name; } if (!string.IsNullOrEmpty(eDeliveryProduct.option2ParentGroupID)) { eDeliveryProduct.option2ParentGroupName = SDeliveryProductsOptions.GetByID(eDeliveryProduct.option2ParentGroupID).name; } if (!string.IsNullOrEmpty(eDeliveryProduct.addon1ParentGroupID)) { eDeliveryProduct.addon1ParentGroupName = SDeliveryProductsAddons.GetByID(eDeliveryProduct.addon1ParentGroupID).name; } if (!string.IsNullOrEmpty(eDeliveryProduct.addon2ParentGroupID)) { eDeliveryProduct.addon2ParentGroupName = SDeliveryProductsAddons.GetByID(eDeliveryProduct.addon2ParentGroupID).name; } if (!string.IsNullOrEmpty(eDeliveryProduct.addon3ParentGroupID)) { eDeliveryProduct.addon3ParentGroupName = SDeliveryProductsAddons.GetByID(eDeliveryProduct.addon3ParentGroupID).name; } return(eDeliveryProduct); }
//=====================================================GETS ABOVE===================================================== #region Remove static public async Task <bool> Remove(string id) { using var context = new SMySQLContext(); EDeliveryProduct eProduct = context.DeliveryProducts.SingleOrDefault(x => x.id == id); if (eProduct == null) { return(false); } context.Remove(eProduct); await context.SaveChangesAsync(); return(true); }
static public async Task <string> Save(EDeliveryProduct eProduct) { using var context = new SMySQLContext(); eProduct.modificationDateUTC = DateTime.UtcNow; if (string.IsNullOrEmpty(eProduct.option1ParentGroupID)) { eProduct.option1ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.option2ParentGroupID)) { eProduct.option2ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.option3ParentGroupID)) { eProduct.option3ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.addon1ParentGroupID)) { eProduct.addon1ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.addon2ParentGroupID)) { eProduct.addon2ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.addon3ParentGroupID)) { eProduct.addon3ParentGroupID = null; } if (string.IsNullOrEmpty(eProduct.id)) { eProduct.id = Guid.NewGuid().ToString(); eProduct.creationDateUTC = DateTime.UtcNow; var e = await context.DeliveryProducts.AddAsync(eProduct); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.DeliveryProducts.Update(eProduct); await context.SaveChangesAsync(); return(e.Entity.id); } }
public async Task <IActionResult> Save([FromBody] EDeliveryProduct eDeliveryProduct) { string id = await SDeliveryProducts.Save(eDeliveryProduct); return(Ok(id)); }
public async Task <IActionResult> GetByID(string id) { EDeliveryProduct eDeliveryProduct = await SDeliveryProducts.GetByID(id); return(Ok(eDeliveryProduct)); }