예제 #1
0
 public void Update(IngredientDetailModel model)
 {
     using (var dbContext = dbContextFactory.CreateDbContext())
     {
         var entity = IngredientMapper.MapIngredientDetailModelToEntity(model);
         dbContext.Ingredients.Update(entity);
         dbContext.SaveChanges();
     }
 }
예제 #2
0
 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));
     }
 }
예제 #3
0
        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));
        }