예제 #1
0
 //[HttpPost]
 //public ActionResult Index(Claim model)
 //{
 //    //var model = new Claim(id);
 //    return View();
 //}
 public JsonResult ClaimSave(int? id, string descr)
 {
     try
     {
         if (!id.HasValue) throw new ArgumentException("Не указана заявка!");
         ResponseMessage responseMessage;
         var model = new Claim();
         model.Id = id.Value;
         model.Descr = descr;
         bool complete = model.Save(out responseMessage);
         if (!complete) throw new Exception(responseMessage.ErrorMessage);
     }
     catch (Exception ex)
     {
         return Json(new { errorMessage = ex.Message });
     }
     return Json(new { });
 }
예제 #2
0
        public ActionResult New(Claim model)
        {
            //if (!CurUser.UserCanCreateClaim()) return RedirectToAction("AccessDenied", "Error");

            //Создаем заявку с основными полями и одельно первый статус с комментарием
            try
            {
                ResponseMessage responseMessage;
                model.Contractor = new Contractor() { Id = MainHelper.GetValueInt(Request.Form["ctrList"]) };
                model.Contract = new Contract() { Id = MainHelper.GetValueInt(Request.Form["contList"]) };
                model.Device = new Device() { Id = MainHelper.GetValueInt(Request.Form["devList"]) };
                model.Descr = Request.Form["descr"];
                model.ClientSdNum = Request.Form["client_sd_num"];
                bool result = model.Save(out responseMessage);
                //var response = DbModel.DeserializeResponse(result);
                if (!result) throw new Exception(responseMessage.ErrorMessage);
                return RedirectToAction("Index", new { id = responseMessage.Id });
            }
            catch (Exception ex)
            {
                TempData["error"] = ex.Message;
                return View("New", model);
            }

            //return RedirectToAction("New", model);
        }