Example #1
0
        public ApplicationMainDO CreateApplication(IntegrationNewAppDO newAppDO)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                ApplicationNewDO applicationNewDO;

                if (newAppDO.ApplicationType != null)
                {
                    var lot = this.lotRepository.GetLotIndex(newAppDO.LotId);

                    List<string> lotCaseTypes = null;
                    IEnumerable<GvaCaseType> caseTypesForSet = this.caseTypeRepository.GetCaseTypesForSet(lot.Set.Alias);
                    if (lot.Set.Alias == "Person")
                    {
                        var personData = lot.Index.GetPart<PersonDataDO>("personData").Content;
                        lotCaseTypes = caseTypesForSet
                            .Where(c => personData.CaseTypes.Contains(c.GvaCaseTypeId))
                            .Select(c => c.Alias).ToList();
                    }
                    else if (lot.Set.Alias == "Aircraft")
                    {
                        var aircraftData = lot.Index.GetPart<AircraftDataDO>("aircraftData").Content;
                        lotCaseTypes = new List<string>() { "aircraft" };
                    }
                    else if (lot.Set.Alias == "Organization")
                    {
                        var organizationData = lot.Index.GetPart<OrganizationDataDO>("organizationData").Content;
                        lotCaseTypes = organizationData.CaseTypes.Select(c => c.Alias).ToList();
                    }

                    var appType = this.nomRepository.GetNomValue(newAppDO.ApplicationType.NomValueId);
                    var caseTypeAlias = appType.TextContent.GetItems<string>("caseTypes").First();
                    var caseType = this.caseTypeRepository.GetCaseType(caseTypeAlias);

                    if (!lotCaseTypes.Contains(caseTypeAlias))
                    {
                        if (lot.Set.Alias == "Person" || lot.Set.Alias == "Organization")
                        {
                            this.integrationRepository.UpdateLotCaseTypes(lot.Set.Alias, caseType, lot, this.userContext);
                        }
                    }

                    applicationNewDO = new ApplicationNewDO()
                    {
                        LotId = newAppDO.LotId,
                        SetPartPath = lot.Set.Alias.ToLower() + "DocumentApplications",
                        Correspondents = new List<int>(),
                        ApplicationType = newAppDO.ApplicationType,
                        CaseTypeId = caseType.GvaCaseTypeId
                    };
                }
                else
                {
                    applicationNewDO = new ApplicationNewDO()
                    {
                        LotId = newAppDO.LotId,
                        Correspondents = new List<int>()
                    };
                }

                ApplicationMainDO newAppMainData = this.applicationRepository.CreateNewApplication(applicationNewDO, this.userContext, newAppDO.DocId);

                transaction.Commit();

                return newAppMainData;
            }
        }
Example #2
0
        public IHttpActionResult PostNewApplication(ApplicationNewDO applicationNewDO)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                ApplicationMainDO newAppMainData = this.applicationRepository.CreateNewApplication(applicationNewDO, this.userContext);

                transaction.Commit();

                return Ok(new
                {
                    LotId = newAppMainData.LotId,
                    GvaApplicationId = newAppMainData.GvaApplicationId,
                    PartIndex = newAppMainData.PartIndex
                });
            }
        }