コード例 #1
0
        public async Task <IActionResult> DisableEnableOfficeAsync([FromBody] DisableEnableOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            var officeModelList = officeAll.Where(a => a.OfficeName == request.OfficeName).ToList();

            var childOffice = officeAll.Where(a => officeAll.Where(aa => aa.OfficeName == request.OfficeName).Select(aa => aa.OfficeGuid).Contains(a.ParentOfficeGuid)).ToList();

            foreach (var item in childOffice)
            {
                item.LastUpdatedBy   = UserID;
                item.LastUpdatedDate = DateTime.Now;
                item.Enable          = request.Enable;
            }
            foreach (var item in officeModelList)
            {
                item.LastUpdatedBy   = UserID;
                item.LastUpdatedDate = DateTime.Now;
                item.Enable          = request.Enable;
            }
            officeModelList.AddRange(childOffice);
            var result = await officeBiz.UpdateAsync(officeModelList);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "修改失败"));
            }
            return(Success());
        }
コード例 #2
0
        public async Task <IActionResult> GetFirstOfficeListAsync()
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync(enable : true);

            officeAll = officeAll.Where(a => a.ParentOfficeGuid == null || !officeAll.Any(b => b.OfficeGuid == a.ParentOfficeGuid)).ToList();
            return(Success(officeAll.Select(a => a.OfficeName).Distinct()));
        }
コード例 #3
0
        public async Task <IActionResult> UpdataOfficeAsync([FromBody] UpdataOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            if (request.ParentName == request.OfficeName)
            {
                return(Failed(ErrorCode.UserData, "一级科室不能是自己"));
            }
            var officeModelList = officeAll.Where(a => a.OfficeName == request.OfficeName).ToList();

            var childOffice = officeAll.Where(a => officeAll.Where(aa => aa.OfficeName == request.OfficeName).Select(aa => aa.OfficeGuid).Contains(a.ParentOfficeGuid)).ToList();

            if (!string.IsNullOrWhiteSpace(request.ParentName) && childOffice.Any())
            {
                return(Failed(ErrorCode.UserData, "此科室存二级科室,不能移动到其他科室下面"));
            }
            //foreach (var item in childOffice)
            //{
            //    item.ParentOfficeGuid = officeAll.FirstOrDefault(b => b.OfficeName == request.OfficeName && b.HospitalGuid == item.HospitalGuid)?.ParentOfficeGuid;
            //}
            foreach (var item in officeModelList)
            {
                item.LastUpdatedBy = UserID;
                item.OfficeName    = request.NewOfficeName;
                if (request.ParentName == null)
                {
                    item.ParentOfficeGuid = null;
                }
                else
                {
                    item.ParentOfficeGuid = officeAll.FirstOrDefault(b => b.OfficeName == request.ParentName && b.HospitalGuid == item.HospitalGuid)?.OfficeGuid;
                }
                item.Recommend   = false;
                item.Enable      = request.Enable;
                item.Sort        = request.Sort;
                item.PictureGuid = request.PictureGuid;
            }
            //officeModelList.AddRange(childOffice);
            var result = await officeBiz.UpdateAsync(officeModelList, request.OfficeName, request.NewOfficeName);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "添加失败"));
            }
            return(Success());
        }
コード例 #4
0
        public async Task <IActionResult> GetDoctorByFirstLevelOfficeNameAsync([FromQuery] GetDoctorByFirstLevelOfficeNameRequestDto requestDto)
        {
            var officeBiz       = new OfficeBiz();
            var levelOneOffices = await officeBiz.GetModelByNameAsync(requestDto.OfficeName);

            var officeIds    = new List <string>();
            var officeModels = await officeBiz.GetAllAsync();

            foreach (var item in levelOneOffices)
            {
                officeIds.AddRange(officeBiz.GetOfficeListByParentOfficeNode(item.OfficeGuid, officeModels));
            }
            requestDto.OfficeIds = officeIds;
            var response = await new DoctorBiz().GetDoctorByFirstLevelOfficeNameAsync(requestDto);

            return(Success(response));
        }
コード例 #5
0
        public async Task <IActionResult> AddOfficeAsync([FromBody] AddOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            if (officeAll.Any(a => a.OfficeName == request.OfficeName.Trim()))
            {
                return(Failed(ErrorCode.UserData, "系统中存在相同的科室名称"));
            }
            var hospitalBiz = new HospitalBiz();
            var hospitalAll = await hospitalBiz.GetAllAsync();

            var officeModelList = new List <OfficeModel>();

            foreach (var item in hospitalAll)
            {
                officeModelList.Add(new OfficeModel
                {
                    CreatedBy        = UserID,
                    LastUpdatedBy    = UserID,
                    Enable           = request.Enable,
                    OrgGuid          = string.Empty,
                    HospitalGuid     = item.HospitalGuid,
                    HospitalName     = item.HosName,
                    OfficeGuid       = Guid.NewGuid().ToString("N"),
                    OfficeName       = request.OfficeName,
                    ParentOfficeGuid = officeAll.FirstOrDefault(b => b.HospitalGuid == item.HospitalGuid && b.OfficeName == request.ParentName)?.OfficeGuid,
                    PictureGuid      = request.PictureGuid,
                    Recommend        = false,
                    Sort             = request.Sort
                });
            }
            var result = await officeBiz.InsertListAsync(officeModelList);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "添加失败"));
            }
            return(Success());
        }