Example #1
0
 public Person AddPersonContacts(params PersonContact[] items)
 {
     foreach (var item in items)
     {
         PersonContacts.Add(item);
     }
     return(this);
 }
Example #2
0
        public int AddPersonContacts(PersonContacts data)
        {
            var checkNumber = _context.PersonContacts.Any(x => x.Email == data.Email || x.PhoneNumber == data.PhoneNumber);

            if (checkNumber)
            {
                return(-1);
            }
            var res = _context.PersonContacts.Add(data);

            _context.SaveChanges();
            return(res.Entity.Id);
        }
Example #3
0
        public bool UpdatePersonContacts(int id, PersonContacts data)
        {
            var res = _context.PersonContacts.FirstOrDefault(x => x.Id == id);

            if (res == null)
            {
                return(false);
            }
            res.PhoneNumber     = data.PhoneNumber;
            res.HomePhoneNumber = data.HomePhoneNumber;
            res.WorkPhoneNumber = data.WorkPhoneNumber;
            res.Email           = data.Email;
            _context.SaveChanges();
            return(true);
        }
Example #4
0
        public void UpdatePersonContact(int id, PersonContactType personContactType, string value)
        {
            var contact = PersonContacts
                          .FirstOrDefault(
                x => x.Id == id && !x.IsDeleted);

            if (contact == null)
            {
                throw new NotFoundException(
                          StringResource.Contact,
                          StringResource.Id,
                          id);
            }

            contact.Update(personContactType, value);
        }
Example #5
0
        public void DeletePersonContact(int id)
        {
            var contact = PersonContacts
                          .FirstOrDefault(
                x => x.Id == id && !x.IsDeleted);

            if (contact == null)
            {
                throw new NotFoundException(
                          StringResource.Contact,
                          StringResource.Id,
                          id);
            }
            else
            {
                contact.Delete();
            }
        }
Example #6
0
        public IActionResult PutPersonContacts(int id, [FromBody] PersonContacts data)
        {
            try
            {
                var res = _repository.UpdatePersonContacts(id, data);

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

                return(Ok(res));
            }
            catch (Exception error)
            {
                return(BadRequest(error));
            }
        }
Example #7
0
        public IActionResult PostPersonContacts(PersonContacts data)
        {
            try
            {
                var res = _repository.AddPersonContacts(data);

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

                return(Ok(res));
            }
            catch (Exception error)
            {
                return(BadRequest(error));
            }
        }
Example #8
0
        /// <summary>
        /// </summary>
        /// <param name="sectionID"></param>
        /// <param name="showOldValues"></param>
        public void LoadPeronInfoFromDoisser(int sectionID, bool showOldValues)
        {
            var contextList = new List <DossierContext>();
            var sqlParams   = new Dictionary <string, object>
            {
                { "@КодЛица", Id.ToInt() }, { "@DateOld", showOldValues ? 1 : 0 }
            };

            if (sectionID != 0)
            {
                sqlParams.Add("@КодВкладки", sectionID);
            }
            using (var dbReader = new DBReader(SQLQueries.SP_Лица_Досье_Context_NEW, CommandType.StoredProcedure, CN,
                                               sqlParams))
            {
                if (dbReader.HasRows)
                {
                    //Unavailable = true;
                    //return;

                    Unavailable = false;
                    //Досье
                    while (dbReader.Read())
                    {
                        if (!dbReader.HasRows)
                        {
                            continue;
                        }
                        if (!dbReader.IsDBNull(dbReader.GetOrdinal("Надпись")) &&
                            dbReader.GetString(dbReader.GetOrdinal("Надпись")) == "ТипЛица")
                        {
                            IsNaturalPerson = dbReader.GetString(dbReader.GetOrdinal("Поле")) == "2";
                        }
                        else
                        {
                            var tempContext = new DossierContext();
                            tempContext.LoadFromDbReader(dbReader);
                            contextList.Add(tempContext);
                        }
                    }
                }


                //Атрибуты
                if ((sectionID == 0 || sectionID == 41) && dbReader.NextResult())
                {
                    PersonAttributes = new List <Attribute>();
                    while (dbReader.Read())
                    {
                        if (dbReader.HasRows)
                        {
                            var tempAttribute = new Attribute();
                            tempAttribute.FillDataFromDataRow(dbReader, true);
                            PersonAttributes.Add(tempAttribute);
                        }
                    }
                }

                //Темы и типы
                if ((sectionID == 0 || sectionID == 42) && dbReader.NextResult())
                {
                    PersonTypes = new List <PersonType>();
                    while (dbReader.Read())
                    {
                        if (dbReader.HasRows)
                        {
                            var tempType = new PersonType();
                            tempType.FillDataFromDataReader(dbReader, true);
                            PersonTypes.Add(tempType);
                        }
                    }
                }

                if (PersonTypes.Count == 0 && PersonAttributes.Count == 0 && contextList.Count == 0)
                {
                    Unavailable = true;
                    return;
                }
            }


            if (sectionID == 0)
            {
                PersonInfo          = contextList.Where(t => t.КодВкладки == (IsNaturalPerson ? 2 : 1)).Select(t => t).ToList();
                PersonContacts      = contextList.Where(t => t.КодВкладки == 7 || t.КодВкладки == 8).Select(t => t).ToList();
                ResponsibleEmployes =
                    contextList.Where(t => t.КодВкладки == 3 || t.КодВкладки == 4).Select(t => t).ToList();
                PersonLinks =
                    contextList.Where(
                        t =>
                        t.КодВкладки == 11 || t.КодВкладки == 12 || t.КодВкладки == 13 || t.КодВкладки == 14 ||
                        t.КодВкладки == 15 || t.КодВкладки == 16 || t.КодВкладки == 17 || t.КодВкладки == 18)
                    .Select(
                        t => t).ToList();

                PersonStores =
                    contextList.Where(
                        t =>
                        t.КодВкладки == 19 || t.КодВкладки == 20 || t.КодВкладки == 21 || t.КодВкладки == 23 ||
                        t.КодВкладки == 40 || t.КодВкладки == 24 || t.КодВкладки == 22 || t.КодВкладки == 25)
                    .Select(
                        t => t).ToList();
            }
            else
            {
                if (sectionID == 7 || sectionID == 8)
                {
                    PersonContacts.RemoveAll(r => r.КодВкладки == sectionID);
                    PersonContacts.AddRange(contextList.Where(t => t.КодВкладки == sectionID).Select(t => t));
                }
                else if (sectionID == 3 || sectionID == 4)
                {
                    ResponsibleEmployes.RemoveAll(r => r.КодВкладки == sectionID);
                    ResponsibleEmployes.AddRange(contextList.Where(t => t.КодВкладки == sectionID).Select(t => t));
                }
                else if (sectionID == 11 || sectionID == 12 || sectionID == 13 || sectionID == 14 || sectionID == 15 ||
                         sectionID == 16 || sectionID == 17 || sectionID == 18)
                {
                    PersonLinks.RemoveAll(r => r.КодВкладки == sectionID);
                    PersonLinks.AddRange(contextList.Where(t => t.КодВкладки == sectionID).Select(t => t));
                }
                else if (sectionID == 19 || sectionID == 20 || sectionID == 21 || sectionID == 22 || sectionID == 23 ||
                         sectionID == 24 || sectionID == 25 || sectionID == 40)
                {
                    PersonStores.RemoveAll(r => r.КодВкладки == sectionID);
                    PersonStores.AddRange(contextList.Where(t => t.КодВкладки == sectionID).Select(t => t));
                }
                else if (sectionID == 1 || sectionID == 2)
                {
                    PersonInfo.RemoveAll(r => r.КодВкладки == (IsNaturalPerson ? 2 : 1));
                    PersonInfo.AddRange(
                        contextList.Where(t => t.КодВкладки == (IsNaturalPerson ? 2 : 1)).Select(t => t));
                }
                else
                {
                    PersonInfo.RemoveAll(r => r.КодВкладки == sectionID);
                    PersonInfo.AddRange(contextList.Where(t => t.КодВкладки == sectionID).Select(t => t));
                }
            }
        }
Example #9
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);
        }