public void Update(IngredientDetailModel model) { using (var dbContext = dbContextFactory.CreateDbContext()) { var entity = IngredientMapper.MapIngredientDetailModelToEntity(model); dbContext.Ingredients.Update(entity); dbContext.SaveChanges(); } }
public IngredientDetailModel Create(IngredientDetailModel model) { using (var dbContext = dbContextFactory.CreateDbContext()) { var entity = IngredientMapper.MapIngredientDetailModelToEntity(model); dbContext.Ingredients.Add(entity); dbContext.SaveChanges(); return(IngredientMapper.MapIngredientEntityToDetailModel(entity)); } }
public IngredientDetailModel InsertOrUpdate(IngredientDetailModel model) { using var dbContext = _dbContextFactory.Create(); var entity = IngredientMapper.MapIngredientDetailModelToEntity(model); dbContext.Ingredients.Update(entity); dbContext.SaveChanges(); return(IngredientMapper.MapIngredientEntityToDetailModel(entity)); }