Example #1
0
 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);
 }
Example #2
0
        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);
        }
Example #3
0
 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);
 }