예제 #1
0
 /// <summary>
 /// Creates the specified model.
 /// </summary>
 /// <param name="model">The model.</param>
 public void Create(Models.Product model)
 {
     try
     {
         var product = _mapper.Map <Product>(model);
         _dbContext.Products.Add(product);
         _dbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         // Log to technology specific error store
         _logging.Error(ex);
         // Bubble up exception.
         throw;
     };
 }
예제 #2
0
 /// <summary>
 /// Updates the specified model.
 /// </summary>
 /// <param name="model">The model.</param>
 public void Update(Models.Product model)
 {
     try
     {
         var product  = _mapper.Map <Product>(model);
         var original = _dbContext.Products.Find(product.Id);
         original.Name          = product.Name;
         original.Price         = product.Price;
         original.DeliveryPrice = product.DeliveryPrice;
         original.Description   = product.Description;
         _dbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         // Log to technology specific error store
         _logging.Error(ex);
         // Bubble up exception.
         throw;
     };
 }