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 });
     }
 }
Example #2
0
 public ActionResult Edit(BuyerViewModel viewModel)
 {
     var req = viewModel.MapTo<SaveBuyerRequest>();
     _buyerService.SaveBuyer(req);
     return RedirectToAction("Index");
 }