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