Example #1
0
        public void Update(ShopAddress shopAddress)
        {
            try
            {
                if (shopAddress == null)
                {
                    throw new ArgumentNullException();
                }

                if (String.IsNullOrEmpty(shopAddress.Name) || String.IsNullOrEmpty(shopAddress.Street) ||
                    String.IsNullOrEmpty(shopAddress.City) || String.IsNullOrEmpty(shopAddress.State))
                {
                    throw new ArgumentException();
                }

                if (shopAddress.Number < 0)
                {
                    throw new ArgumentOutOfRangeException();
                }

                _shopAddressRepository.Update(shopAddress);

                _logger.CreateLog("Database", "Update", "ShopAddress", new string[] { shopAddress.Id.ToString(), shopAddress.Name, shopAddress.Street, shopAddress.Number.ToString(), shopAddress.State });
            }
            catch (Exception ex)
            {
                _logger.CreateLog("Error", ex.ToString());
                throw ex;
            }
        }
 public ActionResult Update(ShopAddressViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var shopAddress = _shopAddressRepository.GetShopAddressById(model.Id);
             PropertyCopy.Copy(model, shopAddress);
             _shopAddressRepository.Update(shopAddress);
             _shopAddressRepository.Save(RequestContext);
         }
         catch (Exception)
         {
             return(View());
         }
         return(RedirectToAction("Index"));
     }
     return(View());
 }