Пример #1
0
 public ActionResult Create(ShopAddressViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (!CheckShopSetting())
             {
                 TempData["WarningCreateShopSetting"] = WarningCreateShopSetting;
                 return(RedirectToAction("Index", "ShopSetting", new { area = "Administrator" }));
             }
             _shopAddressRepository.Add(new ShopAddress()
             {
                 Id            = Guid.NewGuid().ToString(),
                 ShopSettingId = _shopSettingRepository.All.First().Id,
                 MainAddress   = model.MainAddress,
                 Address       = model.Address,
                 Email         = model.Email,
                 Hotline       = model.Hotline
             });
             _shopAddressRepository.Save(RequestContext);
         }
         catch (Exception)
         {
             return(View());
         }
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #2
0
        public ShopAddressViewModel GetShopAddressViewModelById(string id)
        {
            var model = this.All.Where(m => m.Id == id).FirstOrDefault();
            ShopAddressViewModel viewModel = new ShopAddressViewModel();

            PropertyCopy.Copy(model, viewModel);
            return(viewModel);
        }
Пример #3
0
 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());
 }