コード例 #1
0
        public async Task <IActionResult> SaveDoctorCertificateDetailAsync([FromBody] SaveDoctorCertificateDetailRequestDto request)
        {
            CertificateBiz certificateBiz = new CertificateBiz();
            var            certificate    = await certificateBiz.GetAsync(request.DicGuid, request.OwnerGuid);

            if (certificate == null)
            {
                request.CertificateGuid = Guid.NewGuid().ToString("N");
                await new CertificateBiz().InsertAsync(new CertificateModel
                {
                    CertificateGuid = request.CertificateGuid,
                    DicGuid         = request.DicGuid,
                    CreatedBy       = UserID,
                    Enable          = true,
                    LastUpdatedBy   = UserID,
                    OrgGuid         = string.Empty,
                    OwnerGuid       = request.OwnerGuid,
                    PictureGuid     = request.AccessoryGuid
                });
                return(Success());
            }
            else
            {
                await new CertificateBiz().UpdateAsync(new CertificateModel
                {
                    CertificateGuid = request.CertificateGuid,
                    DicGuid         = request.DicGuid,
                    CreatedBy       = UserID,
                    Enable          = true,
                    LastUpdatedBy   = UserID,
                    OrgGuid         = string.Empty,
                    OwnerGuid       = request.OwnerGuid,
                    PictureGuid     = request.AccessoryGuid
                });
            }
            return(Success(request.CertificateGuid));
        }
コード例 #2
0
        public async Task <IActionResult> UpdateDoctorInfoAsync([FromBody] UpdateDoctorInfoRequestDto request)
        {
            var doctorBiz   = new DoctorBiz();
            var doctorModel = await doctorBiz.GetAsync(request.DoctorGuid);

            if (doctorModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!"));
            }
            var userModel = await new UserBiz().GetAsync(request.DoctorGuid);

            if (userModel.Phone != request.Phone)
            {
                UserModel userPhoneModel = await new UserBiz().GetByPnoneAsync(request.Phone);
                if (userPhoneModel != null)
                {
                    return(Failed(ErrorCode.UserData, "用户手机已注册!"));
                }
            }

            var existNumber = await doctorBiz.ExistJobNumber(request.JobNumber, doctorModel.DoctorGuid);

            if (existNumber)
            {
                return(Failed(ErrorCode.DataBaseError, $"工号【{request.JobNumber}】已存在"));
            }

            userModel.UserName        = request.UserName;
            userModel.IdentityNumber  = request.IdentityNumber;
            userModel.Birthday        = request.Birthday;
            userModel.Gender          = request.Gender;
            userModel.Phone           = request.Phone;
            userModel.LastUpdatedBy   = UserID;
            userModel.LastUpdatedDate = DateTime.Now;

            //医生数据
            doctorModel.HospitalGuid       = request.HospitalGuid;
            doctorModel.OfficeGuid         = request.OfficeGuid;
            doctorModel.WorkCity           = string.Join('-', request.WorkCity);
            doctorModel.JobNumber          = request.JobNumber;
            doctorModel.PractisingHospital = request.PractisingHospital;
            doctorModel.Honor           = request.Honor;
            doctorModel.Background      = request.Background;
            doctorModel.TitleGuid       = request.TitleGuid;
            doctorModel.AdeptTags       = Newtonsoft.Json.JsonConvert.SerializeObject(request.AdeptTags);
            doctorModel.IsRecommend     = request.IsRecommend;
            doctorModel.RecommendSort   = request.RecommendSort;
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.LastUpdatedDate = DateTime.Now;
            doctorModel.PortraitGuid    = request.PortraitGuid;

            //医院名称
            var hospitalBiz   = new HospitalBiz();
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;
            //商户配置项证书信息 & 配置项证书附件信息
            var            clientDicGuids = request.Certificates.Select(b => b.DicGuid);
            CertificateBiz certificateBiz = new CertificateBiz();
            var            dbCertificate  = await certificateBiz.GetListAsync(doctorModel.DoctorGuid);

            var dbDicGuids = dbCertificate.Select(b => b.DicGuid);

            var updateCertificate = dbCertificate.Where(a => clientDicGuids.Contains(a.DicGuid)).Select(a =>
            {
                var cc            = request.Certificates.FirstOrDefault(c => c.DicGuid == a.DicGuid);
                a.PictureGuid     = cc.AccessoryGuid;
                a.LastUpdatedBy   = UserID;
                a.LastUpdatedDate = DateTime.Now;
                return(a);
            });
            var addCertificate = request.Certificates.Where(a => !dbDicGuids.Contains(a.DicGuid)).Select(item => new CertificateModel
            {
                CertificateGuid = Guid.NewGuid().ToString("N"),
                PictureGuid     = item.AccessoryGuid,
                OwnerGuid       = doctorModel.DoctorGuid,
                DicGuid         = item.DicGuid,
                CreatedBy       = UserID,
                OrgGuid         = string.Empty,
                LastUpdatedBy   = UserID
            });
            var delCertificate = dbCertificate.Where(a => !clientDicGuids.Contains(a.DicGuid));
            var result         = await doctorBiz.UpdateDoctorAsync(doctorModel, userModel, addCertificate, delCertificate, updateCertificate);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
            }
            return(Success());
        }