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 }); } }
public ActionResult Edit(BuyerViewModel viewModel) { var req = viewModel.MapTo<SaveBuyerRequest>(); _buyerService.SaveBuyer(req); return RedirectToAction("Index"); }
// // GET: /Buyer/Create public ActionResult Create() { var viewModel = new BuyerViewModel(); viewModel.IsActive = true; return View(viewModel); }
public ActionResult AddBuyer() { var viewModel = new BuyerViewModel() { IsActive = true }; return PartialView(viewModel); }