示例#1
0
        /// <summary>
        /// 修改参保人删除状态
        /// </summary>
        /// <param name="request">请求参数</param>
        /// <returns>返回实体</returns>
        public BaseResponse <ApplicantEntity> SaveApplicant(ApplicantEntity request)
        {
            BaseResponse <ApplicantEntity> response = new BaseResponse <ApplicantEntity>();

            try
            {
                //var appcertModel = unitOfWork.GetRepository<NCIA_APPCERT>().dbSet.Where(m => m.APPLICANTID == request.ApplicantId && m.STATUS != (int)EnumAppCertStatus.未提交 && m.STATUS != (int)EnumAppCertStatus.已撤回 && m.ISDELETE != true).ToList();
                var appcertModel = unitOfWork.GetRepository <NCIA_APPCERT>().dbSet.Where(m => m.APPLICANTID == request.ApplicantId && m.ISDELETE != true).ToList();
                if (appcertModel != null && appcertModel.Count > 0)
                {
                    response.ResultCode = 1001; //  当前住民存在申请数据, 建议不要删除
                    return(response);
                }
                else
                {
                    if (request.Lastcertresult == 0 && request.Lasthospresult == 0)
                    {
                        return(base.Save <NCIA_APPLICANT, ApplicantEntity>(request, (q) => q.IDNO.ToUpper().Trim() == request.Idno.ToUpper().Trim()));
                    }
                    else
                    {
                        response.ResultCode = 1001; //  当前住民存在申请数据, 建议不要删除
                        return(response);
                    }
                }
            }
            catch (Exception exception)
            {
                response.ResultMessage = exception.Message;
                throw;
            }
        }
示例#2
0
        public IHttpActionResult Post([FromBody] ApplicantEntity baseRequest)
        {
            baseRequest.Updateby   = SecurityHelper.CurrentPrincipal.UserId.ToString();
            baseRequest.Updatetime = DateTime.Now;
            var response = service.SaveApplicant(baseRequest);

            return(Ok(response));
        }
示例#3
0
 public static Applicant ToService(this ApplicantEntity entity)
 {
     return(entity != null
         ? new Applicant
     {
         Id = entity.Id,
         EGN = entity.EGN,
         DateOfBirth = entity.DateOfBirth,
         FirstName = entity.FirstName,
         MiddleName = entity.MiddleName,
         LastName = entity.LastName,
         PhoneNumber = entity.PhoneNumber,
         EmailAddress = entity.EmailAddress,
         Address = entity.Address,
         City = entity.City
     }
         : null);
 }
示例#4
0
        public static Applicant MapEntityToDto(ApplicantEntity applicant)
        {
            if (applicant == null)
            {
                return(null);
            }

            return(new Applicant
            {
                ID = applicant.ID,
                Address = applicant.Address,
                Age = applicant.Age,
                CountryOfOrigin = applicant.CountryOfOrigin,
                EmailAddress = applicant.EmailAddress,
                FamilyName = applicant.FamilyName,
                Hired = applicant.Hired,
                Name = applicant.Name
            });
        }
示例#5
0
        /// <summary>
        /// 保存参保人数据
        /// </summary>
        /// <param name="request">请求实体</param>
        /// <returns>保存信息</returns>
        public BaseResponse <ApplicantEntity> SaveApplicantInfo(ApplicantEntity request)
        {
            BaseResponse <ApplicantEntity> response = new BaseResponse <ApplicantEntity>();

            try
            {
                if (string.IsNullOrEmpty(request.ApplicantId))
                {
                    #region 新增

                    var info = from a in unitOfWork.GetRepository <NCIA_APPLICANT>().dbSet
                               join nur in unitOfWork.GetRepository <NCI_NURSINGHOME>().dbSet on a.NSID equals nur.NSID
                               select new ApplicantEntity()
                    {
                        Idno     = a.IDNO,
                        Ssno     = a.SSNO,
                        NSID     = a.NSID,
                        Isdelete = a.ISDELETE,
                        OrgName  = nur.NSNAME
                    };
                    List <ApplicantEntity> List = null;
                    if (SecurityHelper.CurrentPrincipal.OrgType == (int)OrgType.Agency)
                    {
                        List = info.Where(m => (m.Idno.ToUpper().Trim() == request.Idno.ToUpper().Trim() || m.Ssno.ToUpper().Trim() == request.Ssno.ToUpper().Trim()) && m.Isdelete == false).ToList();
                    }
                    else if (SecurityHelper.CurrentPrincipal.OrgType == (int)OrgType.NursingHome)
                    {
                        List = info.Where(m => (m.Idno.ToUpper().Trim() == request.Idno.ToUpper().Trim() || m.Ssno.ToUpper().Trim() == request.Ssno.ToUpper().Trim()) && m.Isdelete == false).ToList();
                    }

                    if (List != null && List.Count > 0) //存在重复数据
                    {
                        response.ResultCode = 1001;     //存在相同的数据
                        if (List[0].NSID == SecurityHelper.CurrentPrincipal.OrgId)
                        {
                            response.ResultMessage = "保存失败,当前机构存在相同的身份证号码或者社保卡号的参保人信息!";
                        }
                        else
                        {
                            response.ResultMessage = "保存失败,当前申请人信息已存在于" + List[0].OrgName + ",在护理险资格申请中可通过身份证或社保卡号获取申请人基本资料!";
                        }
                        return(response);
                    }
                    else  // 不存在数据
                    {
                        request.ApplicantId = GenerateCode("ApplicId", EnumCodeKey.ApplicantId);
                        return(base.Save <NCIA_APPLICANT, ApplicantEntity>(request, (q) => q.APPLICANTID == request.ApplicantId));
                    }
                    #endregion
                }
                else
                {
                    #region 修改
                    var info = from a in unitOfWork.GetRepository <NCIA_APPLICANT>().dbSet
                               join nur in unitOfWork.GetRepository <NCI_NURSINGHOME>().dbSet on a.NSID equals nur.NSID
                               select new ApplicantEntity()
                    {
                        Idno        = a.IDNO,
                        Ssno        = a.SSNO,
                        NSID        = a.NSID,
                        Isdelete    = a.ISDELETE,
                        ApplicantId = a.APPLICANTID,
                        OrgName     = nur.NSNAME
                    };
                    info = info.Where(m => m.ApplicantId != request.ApplicantId);
                    List <ApplicantEntity> List = null;
                    if (SecurityHelper.CurrentPrincipal.OrgType == (int)OrgType.Agency)
                    {
                        List = info.Where(m => (m.Idno.ToUpper().Trim() == request.Idno.ToUpper().Trim() || m.Ssno.ToUpper().Trim() == request.Ssno.ToUpper().Trim()) && m.Isdelete == false).ToList();
                    }
                    else if (SecurityHelper.CurrentPrincipal.OrgType == (int)OrgType.NursingHome)
                    {
                        List = info.Where(m => (m.Idno.ToUpper().Trim() == request.Idno.ToUpper().Trim() || m.Ssno.ToUpper().Trim() == request.Ssno.ToUpper().Trim()) && m.Isdelete == false).ToList();
                    }
                    if (List != null && List.Count > 0) //存在重复数据
                    {
                        response.ResultCode = 1001;     //存在相同的数据
                        if (List[0].NSID == SecurityHelper.CurrentPrincipal.OrgId)
                        {
                            response.ResultMessage = "保存失败,当前机构存在相同的身份证号码或者社保卡号的参保人信息!";
                        }
                        else
                        {
                            response.ResultMessage = "保存失败,当前申请人信息已存在于" + List[0].OrgName + ",在护理险资格申请中可通过身份证或社保卡号获取申请人基本资料!";
                        }
                        return(response);
                    }
                    else  // 不存在数据
                    {
                        Mapper.CreateMap <ApplicantEntity, NCIA_APPLICANT>();
                        var applicantModel = unitOfWork.GetRepository <NCIA_APPLICANT>().dbSet.Where(m => m.APPLICANTID == request.ApplicantId).FirstOrDefault();
                        if (applicantModel != null)
                        {
                            //前端js已经控制:编辑时必须数据有变动才可以保存,所以request.IsInsertHistory只会传True过来
                            if (request.IsInsertHistory)
                            {
                                Mapper.CreateMap <NCIA_APPLICANT, NCIA_APPLICANTHISTORY>();
                                var applicantHistoryModel = Mapper.Map <NCIA_APPLICANTHISTORY>(applicantModel);
                                applicantHistoryModel.CREATEBY   = SecurityHelper.CurrentPrincipal.UserId.ToString();
                                applicantHistoryModel.CREATETIME = DateTime.Now;
                                unitOfWork.GetRepository <NCIA_APPLICANTHISTORY>().Insert(applicantHistoryModel);
                            }
                            //如果IdNo有变动,同时更新定点机构精简版长照对应人员的的IdNo
                            if (request.IsIdNoChaged)
                            {
                                var regFileModle = unitOfWork.GetRepository <LTC_REGFILE>().dbSet.Where(m => m.IDNO == applicantModel.IDNO).FirstOrDefault();
                                if (regFileModle != null)
                                {
                                    regFileModle.IDNO = request.Idno;
                                    unitOfWork.GetRepository <LTC_REGFILE>().Update(regFileModle);
                                    var noticeModel = new LTC_NOTIFICATION()
                                    {
                                        SUBJECTS   = regFileModle.NAME + "身份证号变更",
                                        CONTENTS   = regFileModle.NAME + "的身份证号由 " + applicantModel.IDNO + " 变更为 " + request.Idno,
                                        CREATEBY   = SecurityHelper.CurrentPrincipal.UserId.ToString(),
                                        CREATEDATE = DateTime.Now,
                                        ORGID      = regFileModle.ORGID,
                                    };
                                    unitOfWork.GetRepository <LTC_NOTIFICATION>().Insert(noticeModel);
                                }
                                //更新NCIP_RESIDENTMONFEE表的身份证号
                                var residentMonFeeList = unitOfWork.GetRepository <NCIP_RESIDENTMONFEE>().dbSet.Where(m => m.RESIDENTSSID == applicantModel.IDNO).ToList();
                                residentMonFeeList.ForEach(p =>
                                {
                                    p.RESIDENTSSID = request.Idno;
                                    unitOfWork.GetRepository <NCIP_RESIDENTMONFEE>().Update(p);
                                });
                                //更新LTC_MONTHLYPAYLIMIT表的身份证号
                                var monthLyPayLimitList = unitOfWork.GetRepository <LTC_MONTHLYPAYLIMIT>().dbSet.Where(m => m.RESIDENTSSID == applicantModel.IDNO).ToList();
                                monthLyPayLimitList.ForEach(p =>
                                {
                                    p.RESIDENTSSID = request.Idno;
                                    unitOfWork.GetRepository <LTC_MONTHLYPAYLIMIT>().Update(p);
                                });
                            }
                            applicantModel.UPDATEBY   = SecurityHelper.CurrentPrincipal.UserId.ToString();
                            applicantModel.UPDATETIME = DateTime.Now;
                            Mapper.Map(request, applicantModel);
                            unitOfWork.GetRepository <NCIA_APPLICANT>().Update(applicantModel);
                        }
                        else
                        {
                            applicantModel = Mapper.Map <NCIA_APPLICANT>(request);
                            unitOfWork.GetRepository <NCIA_APPLICANT>().Insert(applicantModel);
                        }
                        unitOfWork.Save();
                        Mapper.DynamicMap(applicantModel, request);
                        response.Data = request;
                    }
                    #endregion
                }
            }
            catch (Exception exception)
            {
                response.ResultMessage = exception.Message;
                throw;
            }
            return(response);
        }