Пример #1
0
 public ActionResult AddBuyer(BuyerViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var req = viewModel.MapTo<SaveBuyerRequest>();
         var resp = _buyerService.SaveBuyer(req);
         return Json(resp);
     }
     else
     {
         var errorList = (from item in ModelState
                          where item.Value.Errors.Any()
                          select item.Value.Errors[0].ErrorMessage).ToList();
         return Json(new { IsSuccess = false, Message = errorList });
     }
 }
Пример #2
0
 public ActionResult Edit(BuyerViewModel viewModel)
 {
     var req = viewModel.MapTo<SaveBuyerRequest>();
     _buyerService.SaveBuyer(req);
     return RedirectToAction("Index");
 }
Пример #3
0
 //
 // GET: /Buyer/Create
 public ActionResult Create()
 {
     var viewModel = new BuyerViewModel();
     viewModel.IsActive = true;
     return View(viewModel);
 }
Пример #4
0
 public ActionResult AddBuyer()
 {
     var viewModel = new BuyerViewModel() { IsActive = true };
     return PartialView(viewModel);
 }