示例#1
0
 public ActionResult Update(MobileViewModel mobileViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ViewBag.brands = new SelectList(brandBL.GetBrand(), "BrandId", "BrandName");
             var config = new MapperConfiguration(mapping =>
             {
                 mapping.CreateMap <MobileViewModel, Mobile>();
             });
             IMapper mapper = config.CreateMapper();
             var     mobile = mapper.Map <MobileViewModel, Mobile>(mobileViewModel);
             mobileBL.UpdateMobile(mobile);
             return(RedirectToAction("Display"));
         }
         else
         {
             ModelState.AddModelError("", "Some error occurred");
             return(View());
         }
     }
     catch
     {
         return(RedirectToAction("Error", "Error"));
     }
 }