Пример #1
0
        public IHttpActionResult PostPerson(PersonDO person)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                var newLot = this.lotRepository.CreateLot("Person");

                var personDataPart = newLot.CreatePart("personData", person.PersonData, this.userContext);
                this.caseTypeRepository.AddCaseTypes(newLot, person.PersonData.CaseTypes);

                PartVersion<PersonDocumentIdDO> documentIdPart = null;
                if (person.PersonDocumentId != null)
                {
                    documentIdPart = newLot.CreatePart("personDocumentIds/*", person.PersonDocumentId.Part, this.userContext);
                }

                PartVersion<PersonAddressDO> personAddressPart = null;
                if (person.PersonAddress != null)
                {
                    personAddressPart = newLot.CreatePart("personAddresses/*", person.PersonAddress, this.userContext);
                    var cases = this.caseTypeRepository.GetCaseTypesForSet("person")
                        .Select(ct => new CaseDO()
                        {
                            CaseType = new NomValue()
                            {
                                NomValueId = ct.GvaCaseTypeId,
                                Name = ct.Name,
                                Alias = ct.Alias
                            },
                            IsAdded = true
                        });

                    this.fileRepository.AddFileReferences(personAddressPart.Part, cases);
                }

                PartVersion<InspectorDataDO> inspectorDataPart = null;
                if (person.InspectorData != null)
                {
                    inspectorDataPart = newLot.CreatePart("inspectorData", person.InspectorData, this.userContext);
                }

                PartVersion<ExaminerDataDO> examinerDataPart = null;
                if (person.ExaminerData != null)
                {
                    examinerDataPart = newLot.CreatePart("examinerData", person.ExaminerData, this.userContext);
                }

                newLot.Commit(this.userContext, lotEventDispatcher);

                this.unitOfWork.Save();

                this.lotRepository.ExecSpSetLotPartTokens(personDataPart.PartId);

                if (documentIdPart != null)
                {
                    this.lotRepository.ExecSpSetLotPartTokens(documentIdPart.PartId);
                }

                if (personAddressPart != null)
                {
                    this.lotRepository.ExecSpSetLotPartTokens(personAddressPart.PartId);
                }

                if (inspectorDataPart != null)
                {
                    this.lotRepository.ExecSpSetLotPartTokens(inspectorDataPart.PartId);
                }

                if (examinerDataPart != null)
                {
                    this.lotRepository.ExecSpSetLotPartTokens(examinerDataPart.PartId);
                }

                transaction.Commit();

                return Ok(new { id = newLot.LotId });
            }
        }
Пример #2
0
        public IHttpActionResult GetNewPerson(
            string firstName = null,
            string lastName = null,
            string uin = null,
            bool extendedVersion = true)
        {
            PersonDO newPerson = new PersonDO()
                {
                    PersonData = new PersonDataDO()
                    {
                        FirstName = firstName,
                        LastName = lastName,
                        Uin = uin
                    }
                };

            if (extendedVersion)
            {
                int validTrueId = this.nomRepository.GetNomValue("boolean", "yes").NomValueId;
                newPerson.PersonDocumentId = new CaseTypesPartDO<PersonDocumentIdDO>(new PersonDocumentIdDO()
                {
                    ValidId = validTrueId
                }, new List<CaseDO>());
                newPerson.PersonAddress = new PersonAddressDO()
                {
                    ValidId = validTrueId
                };
            }

            newPerson.PersonData.CountryId = this.nomRepository.GetNomValue("countries", "BG").NomValueId;

            return Ok(newPerson);
        }