Example #1
0
        public int AddPassportData(DocumentPassportData data)
        {
            var checkNumber = _context.DocumentPassportData.Any(x => x.Series == data.Series && x.Number == data.Number);

            if (checkNumber)
            {
                return(-1);
            }
            else
            {
                var res = _context.DocumentPassportData.Add(data);
                _context.SaveChanges();
                return(res.Entity.Id);
            }
        }
Example #2
0
        public IActionResult PutPassportData(int id, [FromBody] DocumentPassportData data)
        {
            try
            {
                var res = _repository.UpdatePassportData(id, data);

                if (!res)
                {
                    return(Conflict(409));
                }

                return(Ok(res));
            }
            catch (Exception error)
            {
                return(BadRequest(error));
            }
        }
Example #3
0
        public IActionResult PostPassportData(DocumentPassportData data)
        {
            try
            {
                var res = _repository.AddPassportData(data);

                if (res == -1)
                {
                    return(Conflict(409));
                }

                return(Ok(res));
            }
            catch (Exception error)
            {
                return(BadRequest(error));
            }
        }
Example #4
0
        public bool UpdatePassportData(int id, DocumentPassportData data)
        {
            var res = _context.DocumentPassportData.FirstOrDefault(x => x.Id == id);

            if (res == null)
            {
                return(false);
            }
            res.CountryId      = data.CountryId;
            res.Series         = data.Series;
            res.Number         = data.Number;
            res.DocumentIssued = data.DocumentIssued;
            res.IssuedDate     = data.IssuedDate;
            res.Code           = data.Code;
            res.Validity       = data.Validity;
            res.personDataId   = data.personDataId;
            _context.SaveChanges();
            return(true);
        }
Example #5
0
        public int AddPersonData(PersonInfoDataModel data)
        {
            var checkNumber = _context.PersonData.Any(x =>
                                                      x.INN == data.INN ||
                                                      x.SNILS == data.SNILS ||
                                                      x.EmployeeId == data.EmployeeId);

            if (checkNumber)
            {
                return(-1);
            }

            PersonContacts personContacts = new PersonContacts()
            {
                PhoneNumber     = data.PersonContacts.PhoneNumber,
                HomePhoneNumber = data.PersonContacts.HomePhoneNumber,
                WorkPhoneNumber = data.PersonContacts.WorkPhoneNumber,
                Email           = data.PersonContacts.Email
            };

            PersonAddress personAddress = new PersonAddress()
            {
                RegistrationAddress = data.PersonAddress.RegistrationAddress,
                RegistrationDate    = data.PersonAddress.RegistrationDate,
                ResidenceAddress    = data.PersonAddress.ResidenceAddress,
                OutsideAddress      = data.PersonAddress.OutsideAddress,
                InformationAddress  = data.PersonAddress.InformationAddress
            };

            var personData = new DataModel.PersonData()
            {
                Birthplace = data.Birthplace,
                INN        = data.INN,
                InformationСitizenshipDateStart = data.InformationСitizenshipDateStart,
                DocumentTypeId            = data.DocumentTypeId,
                ValidityDocumentDateStart = data.ValidityDocumentDateStart,
                PersonContacts            = _context.PersonContacts.Add(personContacts).Entity,
                PersonAddress             = _context.PersonAddress.Add(personAddress).Entity,
                EmployeeId = data.EmployeeId,
                SNILS      = data.SNILS,
                DateBirth  = data.DateBirth,
                Gender     = data.Gender
            };

            var res = _context.PersonData.Add(personData);

            _context.SaveChanges();

            DocumentPassportData documentPassportData = new DocumentPassportData()
            {
                Code           = data.DocumentPassportData.Code,
                CountryId      = data.DocumentPassportData.CountryId,
                Series         = data.DocumentPassportData.Series,
                Number         = data.DocumentPassportData.Number,
                IssuedDate     = data.DocumentPassportData.IssuedDate,
                Validity       = data.DocumentPassportData.Validity,
                DocumentIssued = data.DocumentPassportData.DocumentIssued,
                personDataId   = res.Entity.Id
            };

            _context.DocumentPassportData.Add(documentPassportData);
            _context.SaveChanges();
            return(res.Entity.Id);
        }