예제 #1
0
        public ActionResult Update(int depId)
        {
            var model = new DepartmentAddModel
            {
                Department = _departmentService.GetById(depId),
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Add()
        {
            var model = new DepartmentAddModel
            {
                Department = new Department(),
            };

            return(View(model));
        }
예제 #3
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <GeneralResponse> AddDepartmentAsync(DepartmentAddModel model)
        {
            GeneralResponse response = await departmentRpcClient.AddDepartmentAsync(new AddDepartmentRequest
            {
                DepartmentName       = model.DepartmentName,
                SuperiorDepartmentId = model.SuperiorDepartmentId
            });

            return(response);
        }
예제 #4
0
 public async Task <IActionResult> AddAsync(DepartmentAddModel department)
 {
     return(Ok(
                ServiceResponseHelper
                .GetSuccessResponse(
                    await
                    _manager
                    .AddAsync(department)
                    )
                ));
 }
        public async Task <object> AddDepartmentAsync([FromBody] DepartmentAddModel model)
        {
            GeneralResponse response = await departmentService.AddDepartmentAsync(model);

            if (response.IsSuccess)
            {
                return(Ok());
            }

            return(BadRequest(response.Message));
        }
예제 #6
0
        public async Task <bool> AddAsync(DepartmentAddModel department)
        {
            await _dataContext
            .Departments
            .AddAsync
            (
                _mapper
                .Map <DataEntities.Department>(department)
            );

            await _dataContext.SaveChangesAsync();

            return(true);
        }
        public async Task <IResultModel> Add(DepartmentAddModel model)
        {
            var entity = _mapper.Map <DepartmentEntity>(model);

            if (await _repository.Exists(entity))
            {
                return(ResultModel.HasExists);
            }

            var result = await _repository.AddAsync(entity);

            if (result)
            {
                return(ResultModel.Success(entity.Id));
            }

            return(ResultModel.Failed());
        }
예제 #8
0
        public async Task <IResultModel> Add(DepartmentAddModel model)
        {
            if (await _repository.ExistsName(model.Name, model.ParentId))
            {
                return(ResultModel.Failed("所属部门中已存在名称相同的部门"));
            }
            if (model.Code.NotNull() && await _repository.ExistsCode(model.Code))
            {
                return(ResultModel.Failed("编码已存在"));
            }

            var entity = _mapper.Map <DepartmentEntity>(model);

            entity.FullPath = $"/{entity.Name}";
            //查询父级
            if (model.ParentId.NotEmpty())
            {
                var parent = await _repository.GetAsync(model.ParentId);

                if (parent != null)
                {
                    //设置等级
                    entity.Level = parent.Level++;
                    //设置完整路径
                    entity.FullPath = $"{parent.FullPath}/{entity.Name}";
                }
            }

            var result = await _repository.AddAsync(entity);

            if (result)
            {
                await ClearCache();

                return(ResultModel.Success(entity));
            }

            return(ResultModel.Failed());
        }
        public ActionResult MessageKeyword(DepartmentAddModel m)
        {
            var oldpass = Request.Form["oldpass"];
            var newpass_r = Request.Form["newpass_r"];
            if (string.IsNullOrWhiteSpace(oldpass) || string.IsNullOrWhiteSpace(newpass_r) ||
                string.IsNullOrWhiteSpace(m.u.登录信息.密码))
            {
                return Content("<script>alert('请将信息输入完整');window.location='/单位用户后台/MessageKeyword';</script>");
            }

            //新输入的密码
            var code = Hash.Compute(m.u.登录信息.密码);

            //原密码与当前密码是否匹配
            if (Hash.Compute(oldpass) == currentUser.登录信息.密码)
            {
                //两次输入的新密码是否一致
                if (m.u.登录信息.密码 == newpass_r)
                {
                    currentUser.登录信息.密码 = code;
                    用户管理.更新用户<单位用户>(currentUser);
                    this.HttpContext.登出();
                    return Content("<script>alert('修改成功,请重新登录!');window.location='/首页/Index';</script>");
                    //return RedirectToAction("Index", "首页");
                }
                else
                {
                    return Content("<script>alert('两次密码不一致!');window.location='/单位用户后台/MessageKeyword';</script>");
                }
            }
            else
            {
                return Content("<script>alert('原密码不正确!');window.location='/单位用户后台/MessageKeyword';</script>");
            }
        }
예제 #10
0
        public ActionResult DepartmentAdd(DepartmentAddModel model)
        {
            if (-1 != 用户管理.检查用户是否存在(model.loginName, true, true))
            {
                return Content("<script>alert('该用用户名已经存在,请重新填写!');location.href='javascript:history.go(-1)';</script>");
            }
            var usergroup = Request.Form["usergroup"];
            bool IsTrue = false;
            if (ModelState.IsValidField("u.单位信息.单位代号") && ModelState.IsValidField("u.登录信息.密码"))
            {
                IsTrue = true;
            }
            if (IsTrue)
            {

                var p = Request["deliverprovince"];
                var c = Request["delivercity"];
                var a = Request["deliverarea"];
                model.u.单位信息.单位编码 = string.Empty;
                model.u.登录信息.登录名 = model.loginName;
                model.u.所属地域.省份 = p;
                model.u.所属地域.城市 = c;
                model.u.所属地域.区县 = a;

                if (!string.IsNullOrWhiteSpace(usergroup))
                {
                    var _f = usergroup.Split(',');
                    for (int i = 0; i < _f.Length - 1; i++)
                    {
                        model.u.用户组.Add(_f[i]);
                    }
                }
                if (Request.Form["admin"] != "-1")
                {
                    model.u.所属单位.用户ID = long.Parse(Request.Form["admin"]);
                }
                用户管理.添加单位用户(model.u,currentUser);
            }
            return Content("<script>alert('添加成功!');location.href='/单位用户后台/departmentadd';</script>");
        }
예제 #11
0
 public Task <IResultModel> Add(DepartmentAddModel model)
 {
     return(_service.Add(model));
 }