예제 #1
0
        public ActionResult ClientStatuses_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);
            var mng = new CRMManager();
            try
            {
                var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary<string, object>).ToList();
                var newClientStatuses = new crm_clientStatuses
                {
                    id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)),
                    name = (AjaxModel.GetValueFromSaveField("name", fields)),
                    code = (AjaxModel.GetValueFromSaveField("code", fields)),
                    color = (AjaxModel.GetValueFromSaveField("color", fields)),
                    state = (AjaxModel.GetValueFromSaveField("state", fields))
                };

                mng.SaveClientStatus(newClientStatuses);
                return Json(new
                {
                    result = true,
                    id = newClientStatuses.id,
                    mng = "Операция прошла успешно"
                },JsonRequestBehavior.AllowGet);
            }
            catch(Exception ex)
            {
                RDL.Debug.LogError(ex);
                return Json(new
                {
                    result = false,
                    id = 0,
                    mng = "Ошибка"
                }, JsonRequestBehavior.AllowGet);
            }

        }