Beispiel #1
0
 public ActionResult SubmitForm(TbSysMenuRequset request, string type)
 {
     if (type == "add")
     {
         var data = _sysMenu.Insert(request);
         return(Content(data.ToJson()));
     }
     else
     {
         var data = _sysMenu.Update(request);
         return(Content(data.ToJson()));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 新增数据(单条)
        /// </summary>
        public AjaxResult Insert(TbSysMenuRequset request)
        {
            if (request == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            try
            {
                var model = MapperHelper.Map <TbSysMenuRequset, TbSysMenu>(request);

                #region 将按钮的bool值转换为int值

                if (!string.IsNullOrWhiteSpace(model.OperationAdd))
                {
                    if (model.OperationAdd == "true")
                    {
                        model.OperationAdd = "1";
                    }
                    else
                    {
                        model.OperationAdd = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationEdit))
                {
                    if (model.OperationEdit == "true")
                    {
                        model.OperationEdit = "1";
                    }
                    else
                    {
                        model.OperationEdit = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationDel))
                {
                    if (model.OperationDel == "true")
                    {
                        model.OperationDel = "1";
                    }
                    else
                    {
                        model.OperationDel = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationView))
                {
                    if (model.OperationView == "true")
                    {
                        model.OperationView = "1";
                    }
                    else
                    {
                        model.OperationView = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOutput))
                {
                    if (model.OperationOutput == "true")
                    {
                        model.OperationOutput = "1";
                    }
                    else
                    {
                        model.OperationOutput = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationExamination))
                {
                    if (model.OperationExamination == "true")
                    {
                        model.OperationExamination = "1";
                    }
                    else
                    {
                        model.OperationExamination = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOther1))
                {
                    if (model.OperationOther1 == "true")
                    {
                        model.OperationOther1 = "1";
                    }
                    else
                    {
                        model.OperationOther1 = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOther2))
                {
                    if (model.OperationOther2 == "true")
                    {
                        model.OperationOther2 = "1";
                    }
                    else
                    {
                        model.OperationOther2 = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOther3))
                {
                    if (model.OperationOther3 == "true")
                    {
                        model.OperationOther3 = "1";
                    }
                    else
                    {
                        model.OperationOther3 = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOther4))
                {
                    if (model.OperationOther4 == "true")
                    {
                        model.OperationOther4 = "1";
                    }
                    else
                    {
                        model.OperationOther4 = "0";
                    }
                }
                if (!string.IsNullOrWhiteSpace(model.OperationOther5))
                {
                    if (model.OperationOther5 == "true")
                    {
                        model.OperationOther5 = "1";
                    }
                    else
                    {
                        model.OperationOther5 = "0";
                    }
                }
                #endregion

                var count = Repository <TbSysMenu> .Insert(model);

                if (count > 0)
                {
                    return(AjaxResult.Success());
                }
                return(AjaxResult.Error("操作失败"));
            }
            catch (Exception)
            {
                return(AjaxResult.Error("操作失败"));
            }
        }