示例#1
0
        public ActionResult Create(Manager model)
        {
            var jm = new JsonWithUIcallback();

            try
            {
                if (ModelState.IsValid)
                {
                    model.Password = ToolsHelper.Md5(model.Password);
                    model.AddTime  = DateTime.Now;

                    var bl = _bll.Insert(model) > 0;
                    jm.statusCode   = bl ? 200 : 300;
                    jm.message      = (bl ? KeyWordsHelper.CreateSuccess : KeyWordsHelper.CreateFailure);
                    jm.closeCurrent = bl;
                    jm.tabid        = bl ? "ManagerList" : "";
                }
                else
                {
                    jm.message = KeyWordsHelper.DataParameterError;
                }
            }
            catch (Exception ex)
            {
                ComToolsController.AddtxtLog(ex, "创建提交", EnumHelper.Nlog.Error.ToString());
                jm.statusCode   = 300;
                jm.message      = ex.ToString();
                jm.closeCurrent = true;
            }
            return(Json(jm));
        }
示例#2
0
        public ActionResult Edit(Manager model)
        {
            var jm = new JsonWithUIcallback();

            try
            {
                if (!ModelState.IsValid)
                {
                    jm.message = KeyWordsHelper.DataParameterError;
                    return(Json(jm));
                }
                var oldModel = _bll.QueryToEnetity(p => p.Id == model.Id);
                if (oldModel == null)
                {
                    jm.statusCode   = 300;
                    jm.message      = "不存在此信息";
                    jm.closeCurrent = true;
                    return(Json(jm));
                }
                //事物处理过程开始
                if (!string.IsNullOrEmpty(model.Password))
                {
                    var pwd = ToolsHelper.Md5(model.Password);
                    oldModel.Password = pwd;
                }
                oldModel.Nickname    = model.Nickname;
                oldModel.RoleId      = model.RoleId;
                oldModel.IsLock      = model.IsLock;
                oldModel.IsSystem    = model.IsSystem;
                oldModel.Description = model.Description;
                //事物处理过程结束
                var bl = _bll.Update(oldModel) > 0;
                jm.statusCode   = bl ? 200 : 300;
                jm.message      = bl ? KeyWordsHelper.EditSuccess : KeyWordsHelper.EditFailure;
                jm.closeCurrent = bl;
                jm.tabid        = bl ? "ManagerList" : "";
            }
            catch (Exception ex)
            {
                ComToolsController.AddtxtLog(ex, "创建提交", EnumHelper.Nlog.Error.ToString());
                jm.statusCode   = 300;
                jm.message      = ex.ToString();
                jm.closeCurrent = true;
            }
            return(Json(jm));
        }