Пример #1
0
        public async Task BackCreateApplication(PrlAppDetailDTO model, Guid?orgId, string appSort)
        {
            if (orgId == null)
            {
                throw new Exception();
            }

            var organizationInfo = DataService.GetEntity <OrganizationInfo>(x => x.IsActualInfo && x.OrganizationId == orgId)
                                   .FirstOrDefault();

            _objectMapper.Map(organizationInfo, model);
            var address = DataService.GetDto <AtuSubjectAddressDTO>(x => x.Id == model.AddressId).FirstOrDefault();

            if (address != null)
            {
                _objectMapper.Map(address, model);
            }

            model.Id      = Guid.Empty;
            model.AppSort = appSort;
            var org = DataService.GetEntity <OrganizationExt>(x => x.Id == orgId).FirstOrDefault();

            if (org == null)
            {
                throw new Exception();
            }

            if (!string.IsNullOrEmpty(org.EDRPOU))
            {
                model.EDRPOU = org.EDRPOU;
            }
            else
            {
                model.INN = org.INN;
            }

            model.OrgUnitId = orgId.Value;

            // Тут работал Макс
            // model.EMail = org.EMail;
        }
Пример #2
0
        public async Task <Guid> SaveApplication(PrlAppDetailDTO editModel, bool isBackOffice)
        {
            Guid appId;
            var  userInfo = await _userInfoService?.GetCurrentUserInfoAsync();

            var isNew = false;

            if (editModel.Id == Guid.Empty)
            {
                isNew = true;
                var model = new PrlAppDetailDTO();
                _objectMapper.Map(editModel, model);
                if (model.OrgUnitId == Guid.Empty)
                {
                    model.OrgUnitId = new Guid(userInfo.OrganizationId());
                }
                if (isBackOffice)
                {
                    model.IsCreatedOnPortal  = false;
                    model.BackOfficeAppState = "Project";
                }
                else
                {
                    model.AppState          = "Project";
                    model.IsCreatedOnPortal = true;
                }
                model.AppType = "PRL";

                var organizationInfo = new OrganizationInfo();
                organizationInfo.OrganizationId = model.OrgUnitId == Guid.Empty ? new Guid(userInfo?.OrganizationId()) : model.OrgUnitId;
                organizationInfo.Type           = "PRL";
                if (string.IsNullOrEmpty(model.EDRPOU))
                {
                    if (isBackOffice == false)
                    {
                        organizationInfo.OrgDirector = userInfo.FullName();
                    }
                }
                else
                {
                    organizationInfo.OrgDirector = model.OrgDirector;
                }
                organizationInfo.Name                        = model.OrgName;
                organizationInfo.EMail                       = model.EMail;
                organizationInfo.LegalFormType               = model.LegalFormType;
                organizationInfo.OwnershipType               = model.OwnershipType;
                organizationInfo.PhoneNumber                 = model.PhoneNumber;
                organizationInfo.FaxNumber                   = model.FaxNumber;
                organizationInfo.NationalAccount             = model.NationalAccount;
                organizationInfo.InternationalAccount        = model.InternationalAccount;
                organizationInfo.NationalBankRequisites      = model.NationalBankRequisites;
                organizationInfo.InternationalBankRequisites = model.InternationalBankRequisites;
                organizationInfo.PassportSerial              = model.PassportSerial;
                organizationInfo.PassportNumber              = model.PassportNumber;
                organizationInfo.PassportDate                = model.PassportDate;
                organizationInfo.PassportIssueUnit           = model.PassportIssueUnit;
                organizationInfo.AddressId                   = model.AddressId;


                var license = _prlLicenseService.GetLicenseGuid(model.OrgUnitId);
                if (license == null)
                {
                    if (editModel.AppSort == "AdditionalInfoToLicense")
                    {
                        organizationInfo.IsPendingLicenseUpdate = true;
                    }
                    organizationInfo.IsActualInfo = true;
                    DataService.GetEntity <OrganizationInfo>(x =>
                                                             x.IsActualInfo && x.OrganizationId == model.OrgUnitId && x.Type == "PRL").ToList()
                    .ForEach(x => x.IsActualInfo = false);
                }

                DataService.Add(organizationInfo);
                DataService.SaveChanges();
                model.OrganizationInfoId = organizationInfo.Id;

                var organization = DataService.GetEntity <OrganizationExt>()
                                   .SingleOrDefault(x => x.Id == model.OrgUnitId);
                if (string.IsNullOrEmpty(model.EDRPOU))
                {
                    organization.INN = model.INN;
                }

                // Тут работал Макс
                // organization.EMail = model.EMail;
                appId = DataService.Add <PrlApplication>(model);

                await DataService.SaveChangesAsync();
            }
            else
            {
                if (isBackOffice)
                {
                    editModel.IsCreatedOnPortal  = false;
                    editModel.BackOfficeAppState = "Project";
                }
                else
                {
                    editModel.AppState          = "Project";
                    editModel.IsCreatedOnPortal = true;
                }
                var organizationInfo = DataService.GetEntity <OrganizationInfo>()
                                       .SingleOrDefault(x => x.Id == editModel.OrganizationInfoId);

                organizationInfo.LegalFormType               = editModel.LegalFormType;
                organizationInfo.OwnershipType               = editModel.OwnershipType;
                organizationInfo.PhoneNumber                 = editModel.PhoneNumber;
                organizationInfo.FaxNumber                   = editModel.FaxNumber;
                organizationInfo.NationalAccount             = editModel.NationalAccount;
                organizationInfo.InternationalAccount        = editModel.InternationalAccount;
                organizationInfo.NationalBankRequisites      = editModel.NationalBankRequisites;
                organizationInfo.InternationalBankRequisites = editModel.InternationalBankRequisites;
                organizationInfo.PassportSerial              = editModel.PassportSerial;
                organizationInfo.PassportNumber              = editModel.PassportNumber;
                organizationInfo.PassportDate                = editModel.PassportDate;
                organizationInfo.PassportIssueUnit           = editModel.PassportIssueUnit;
                organizationInfo.OrgDirector                 = editModel.OrgDirector;
                organizationInfo.AddressId                   = editModel.AddressId;
                organizationInfo.EMail = editModel.EMail;

                // Тут работал Макс
                // var organization = DataService.GetEntity<OrganizationExt>().SingleOrDefault(x => x.Id == editModel.OrgUnitId);
                // organization.EMail = editModel.EMail;

                appId = DataService.Add <PrlApplication>(editModel);
                await DataService.SaveChangesAsync();
            }

            if (editModel.AppSort == "AdditionalInfoToLicense" && isNew)
            {
                var license = (await _limsExchangeService
                               .GetLicenses("PRL", string.IsNullOrEmpty(editModel.EDRPOU) ? editModel.INN : editModel.EDRPOU)).FirstOrDefault();
                if (license == null)
                {
                    throw new Exception();
                }
                foreach (var branchLicense in license.Branches)
                {
                    var branch = new Branch
                    {
                        Id             = Guid.NewGuid(),
                        OrganizationId = editModel.OrgUnitId == Guid.Empty
                            ? new Guid(userInfo?.OrganizationId())
                            : editModel.OrgUnitId,
                        OldLimsId = branchLicense.Id,
                        Name      = branchLicense.Name
                    };
                    var branchId  = DataService.Add(branch, false);
                    var appBranch = new ApplicationBranch()
                    {
                        LimsDocumentId = appId,
                        BranchId       = branchId
                    };
                    DataService.Add(appBranch, false);
                    await DataService.SaveChangesAsync();
                }
                ;
            }

            return(appId);
        }
Пример #3
0
        public IActionResult CreateNewPRLLicenseApplication()
        {
            var abjAdd   = _dataService.GetEntity <SubjectAddress>().FirstOrDefault();
            var userInfo = _userInfoService.GetCurrentUserInfo();
            var appDTO   = new PrlAppDetailDTO()
            {
                Id                          = Guid.Empty,
                Caption                     = null,
                OrgUnitId                   = Guid.Empty,
                OrganizationInfoId          = Guid.Empty,
                OrgName                     = userInfo.OrganizationName(),
                EDRPOU                      = userInfo.EDRPOU(),
                INN                         = userInfo.INN(),
                LegalFormType               = "470",
                PassportSerial              = null,
                PassportNumber              = null,
                OwnershipType               = "32",
                PassportDate                = null,
                PassportIssueUnit           = null,
                OrgDirector                 = null,
                EMail                       = $"{CreateString(5)}@mail.com",
                PhoneNumber                 = CreateNumericString(10),
                FaxNumber                   = CreateNumericString(10),
                StreetId                    = Guid.Empty,
                StreetName                  = null,
                CityId                      = Guid.Empty,
                CityName                    = null,
                CityEnum                    = null,
                PostIndex                   = null,
                RegionId                    = Guid.Empty,
                RegionName                  = null,
                DistrictName                = null,
                Building                    = null,
                AddressType                 = null,
                AddressId                   = abjAdd.Id,
                NationalAccount             = $"NationalAccount:{CreateString(10)}",
                NationalBankRequisites      = $"NationalBankRequisites:{CreateString(10)}",
                InternationalAccount        = $"InternationalAccount:{CreateString(10)}",
                InternationalBankRequisites = $"InternationalBankRequisites:{CreateString(10)}",
                Duns                        = $"Duns:{CreateString(10)}",
                AppType                     = "PRL",
                AppSort                     = "GetLicenseApplication",
                LegalFormName               = null,
                OwnershipTypeName           = null,
                IsCheckMpd                  = true,
                IsPaperLicense              = true,
                IsCourierDelivery           = true,
                IsPostDelivery              = true,
                IsAgreeLicenseTerms         = true,
                IsAgreeProcessingData       = true,
                IsProtectionFromAggressors  = true,
                IsCourierResults            = true,
                IsPostResults               = true,
                IsElectricFormResults       = true,
                AppState                    = "Project",
                BackOfficeAppState          = null,
                Comment                     = $"comment{CreateString(20)}",
                DecisionType                = null,
                PerformerId                 = null,
                RegNumber                   = null,
                RegDate                     = null,
                ExpertiseResultEnum         = null,
                ExpertiseResult             = null,
                ExpertiseDate               = null,
                PerformerOfExpertise        = null,
                IsCreatedOnPortal           = true
            };

            if (string.IsNullOrEmpty(userInfo?.EDRPOU()))
            {
                appDTO.OrgName = userInfo.FullName();
            }

            var appId = _prlApplicationService.SaveApplication(appDTO).Result;

            var branchCount = _rand.Next(1, 3);
            var branchIds   = new List <Guid>();

            while (branchCount > 0)
            {
                branchCount--;
                var branch = new BranchDetailsDTO
                {
                    Id                             = Guid.Empty,
                    Caption                        = null,
                    ApplicationId                  = appId,
                    OrganizationId                 = Guid.Parse(userInfo.OrganizationId()),
                    AppType                        = "PRL",
                    ApplicationBranchId            = default,