Пример #1
0
        public IActionResult Post([FromBody] ViewModel.DeptViewModel createDeptViewModel)
        {
            /*判断是否合法*/
            if (ModelState.IsValid)
            {
                try
                {
                    string strTips   = string.Empty;
                    bool   isDeptAdd = HelpCenter.BLL.Dept.Add(User.Identities.First(u => u.IsAuthenticated).FindFirst("UsrId").Value, createDeptViewModel.PreDeptId, createDeptViewModel.DeptName,
                                                               createDeptViewModel.DeptAccount, createDeptViewModel.DeptPsw, out strTips);
                    /*判断是否新增成功*/
                    return(Ok(new { result = isDeptAdd, tips = strTips }));
                }
                catch (Exception e)
                {
                    return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_EXCEPTION + e.Message.ToString() }));
                }
            }

            return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_DATA_FORMAT_ERROR }));
        }
Пример #2
0
        public IActionResult Put(string deptId, [FromBody] ViewModel.DeptViewModel updateDeptViewModel)
        {
            /*判断是否合法*/
            if (ModelState.IsValid)
            {
                try
                {
                    bool isDeptUpdate = HelpCenter.BLL.Dept.Update(User.Identities.First(u => u.IsAuthenticated).FindFirst("UsrId").Value, deptId, updateDeptViewModel.PreDeptId, updateDeptViewModel.DeptName,
                                                                   updateDeptViewModel.DeptNO, updateDeptViewModel.DeptAccount, updateDeptViewModel.DeptPsw);
                    /*判断是否新增成功*/
                    return(!isDeptUpdate
                        ? Ok(new { result = false, tips = ResponseMessageTips.MSG_DEPT_UPDATE_FAIL })
                        : Ok(new { result = true, tips = ResponseMessageTips.MSG_DEPT_UPDATE_SUCCESS }));
                }
                catch (Exception e)
                {
                    return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_EXCEPTION + e.Message.ToString() }));
                }
            }

            return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_DATA_FORMAT_ERROR }));
        }