/// <summary>
        /// 新增医护人员
        /// </summary>
        /// <param name="input">医护人员信息</param>
        /// <returns>是否成功</returns>
        public async Task <OutputBase> Add(AdminDoctorDto input)
        {
            if (await _repository.GetDoctorByPhone(input.Phone) != null)
            {
                return(OutputBase.Fail("该手机号已经注册"));
            }

            var doctor = new Doctor
            {
                Brithdate        = input.Brithdate,
                DeptId           = input.DeptId,
                HospitalId       = input.HospitalId,
                Name             = input.Name,
                Phone            = input.Phone,
                SelfDesc         = input.SelfDesc,
                Sex              = input.Sex,
                UserType         = input.UserType,
                TitleId          = input.TitleId,
                DialysisDoctorId = string.Empty,//默认
                IsDelete         = false
            };

            _repository.Add(doctor);

            return(_unitWork.Commit() ? OutputBase.Success("新增成功") : OutputBase.Fail("新增失败"));
        }
        /// <summary>
        /// 更新医护人员
        /// </summary>
        /// <param name="input">医护人员信息</param>
        /// <returns>是否成功</returns>
        public async Task <OutputBase> Update(AdminDoctorDto input)
        {
            var doctor = await _repository.GetDoctorById(input.Id);

            if (doctor == null)
            {
                return(OutputBase.Fail("该医护人员不存在"));
            }
            if (doctor.Phone != input.Phone && await _repository.GetDoctorByPhone(input.Phone) != null)
            {
                return(OutputBase.Fail("该手机号已经注册"));
            }

            var entity = new Doctor
            {
                Id         = input.Id,
                Brithdate  = input.Brithdate,
                DeptId     = input.DeptId,
                HospitalId = input.HospitalId,
                Name       = input.Name,
                Phone      = input.Phone,
                SelfDesc   = input.SelfDesc,
                Sex        = input.Sex,
                UserType   = input.UserType,
                TitleId    = input.TitleId
            };
            await _repository.Update(entity);

            return(_unitWork.Commit() ? OutputBase.Success("更新成功") : OutputBase.Fail("更新失败"));
        }
        public async Task <IActionResult> Edit(AdminDoctorDto model)
        {
            if (!ModelState.IsValid)
            {
                await ShowHospitalList(false);

                ViewBag.SexList      = EnumExtensionHelper.EnumToSelectList <SexEnum>(false);
                ViewBag.UserTypeList = EnumExtensionHelper.EnumToSelectList <UserTypeEnum>(false);
                ViewBag.DeptList     = EnumExtensionHelper.EnumToSelectList <DeptEnum>(false);
                ViewBag.TitleList    = EnumExtensionHelper.EnumToSelectList <TitleEnum>(false);
                return(PartialView("_EditPartial", model));
            }

            if (model.HospitalId < 1 && !CurrentLoginUser.IsSuperManager)
            {
                model.HospitalId = CurrentLoginUser.HospitalId.Value;
            }

            //主键初始Id大于0表示是编辑,反之则是新增
            if (model.Id > 0)
            {
                var result = await _service.Update(model);

                return(Json(result));
            }
            else
            {
                var result = await _service.Add(model);

                return(Json(result));
            }
        }