示例#1
0
 public ActionResult Edit(VesselViewModel viewModel)
 {
     var req = viewModel.MapTo<SaveVesselRequest>();
     _vesselService.SaveVessel(req);
     return RedirectToAction("Index");
 }
 public ActionResult AddVessel(VesselViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var req = viewModel.MapTo<SaveVesselRequest>();
         var resp = _vesselService.SaveVessel(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 });
     }
 }