public async Task <bool> Create(FoodGrouping FoodGrouping) { FoodGroupingDAO FoodGroupingDAO = new FoodGroupingDAO(); FoodGroupingDAO.Id = FoodGrouping.Id; FoodGroupingDAO.Name = FoodGrouping.Name; FoodGroupingDAO.StatusId = FoodGrouping.StatusId; DataContext.FoodGrouping.Add(FoodGroupingDAO); await DataContext.SaveChangesAsync(); FoodGrouping.Id = FoodGroupingDAO.Id; await SaveReference(FoodGrouping); return(true); }
public async Task <bool> BulkMerge(List <FoodGrouping> FoodGroupings) { List <FoodGroupingDAO> FoodGroupingDAOs = new List <FoodGroupingDAO>(); foreach (FoodGrouping FoodGrouping in FoodGroupings) { FoodGroupingDAO FoodGroupingDAO = new FoodGroupingDAO(); FoodGroupingDAO.Id = FoodGrouping.Id; FoodGroupingDAO.Name = FoodGrouping.Name; FoodGroupingDAO.StatusId = FoodGrouping.StatusId; FoodGroupingDAOs.Add(FoodGroupingDAO); } await DataContext.BulkMergeAsync(FoodGroupingDAOs); return(true); }
public async Task <bool> Update(FoodGrouping FoodGrouping) { FoodGroupingDAO FoodGroupingDAO = DataContext.FoodGrouping.Where(x => x.Id == FoodGrouping.Id).FirstOrDefault(); if (FoodGroupingDAO == null) { return(false); } FoodGroupingDAO.Id = FoodGrouping.Id; FoodGroupingDAO.Name = FoodGrouping.Name; FoodGroupingDAO.StatusId = FoodGrouping.StatusId; await DataContext.SaveChangesAsync(); await SaveReference(FoodGrouping); return(true); }