public JsonResult Delete(RiskViewModel riskModel) { var rm = new ResponseMessage(); try { var risk = Mapper.Map<Risk>(riskModel); riskRepository.Delete(risk); rm.Data = risk; } catch { rm.Message = "Error occurred, please try again."; } return Json(rm); }
public JsonResult Create(RiskViewModel riskModel) { var rm = new ResponseMessage(); if (ModelState.IsValid) { try { var risk = Mapper.Map<Risk>(riskModel); riskRepository.Add(risk); rm.Data = risk; } catch { rm.Message = "Error occurred, please try again."; } } else rm.Message = ModelState.GetErrors(); return Json(rm); }
public JsonResult Save(RiskViewModel riskModel) { var rm = new ResponseMessage(); try { if (!ModelState.IsValid) { rm.Message = ModelState.GetErrors(); return Json(rm); } var risk = Mapper.Map<Risk>(riskModel); riskRepository.Update(risk); } catch { rm.Message = "Error occurred, please try again."; } return Json(rm); }