private void ActionPerson(RawBulkPerson rawPerson) { try { if (rawPerson.IsValid) { string personRawName = rawPerson.name.Data; Person person = Person.CreatePerson(); ContactHandler(person, rawPerson.phone1, rawPerson.phone2, rawPerson.email1, rawPerson.email2); person.Description = "Name: " + personRawName; if (rawPerson.company.IsValid) { person.Description += " Company: " + rawPerson.company.Data; } if (rawPerson.NMS.IsValid) { person.Description += " FIO: " + rawPerson.NMS.Data; } rawPassportList.ForEach((rawPassport) => { ActionPersonByPassport(rawPerson, rawPassport, person); }); rawMileCardList.ForEach((rawMileCard) => { ActionPersonByMileCard(rawPerson, rawMileCard, person); }); person.Save(); } rawPerson.IsHandled = true; } catch { failedPerson.Add(rawPerson); } }
private void ActionPersonByMileCard(RawBulkPerson rawPerson, RawBulkMileCard rawMileCard, Person person) { if (rawMileCard.IsValid && (rawMileCard.owner.Data == rawPerson.name.Data)) { AviaCompany aviaCompany = aviaCompanyList.Find((item) => item.FullName == rawMileCard.company.Data); if (aviaCompany != null) { MileCard mileCard = person.mileCardList.Create(); mileCard.AviaCompanyID = aviaCompany.ID; mileCard.Number = rawMileCard.number.Data; mileCard.Save(); } else { person.Description += " Mile card: " + rawMileCard.company.Data + " " + rawMileCard.number.Data; } } rawMileCard.IsHandled = true; }
private void ActionPersonByPassport(RawBulkPerson rawPerson, RawBulkPassport rawPassport, Person person) { if (rawPassport.IsValid && (rawPassport.owner.Data == rawPerson.name.Data)) { person.FirstName = rawPassport.FirstName.Data; person.SecondName = rawPassport.SecondName.Data; person.MiddleName = rawPassport.Middle.Data; int year = Convert.ToInt32(rawPassport.yearBirth.Data); int month = Convert.ToInt32(rawPassport.monthBirth.Data); int day = Convert.ToInt32(rawPassport.dayBirth.Data); person.Birth = new DateTime(year, month, day); if (rawPassport.gender.IsValid) { person.Gender = rawPassport.gender.Data.ToLower(); } Passport passport = person.PassportList.Create(); passport.SerialNumber = rawPassport.number.Data; year = Convert.ToInt32(rawPassport.yearValid.Data); month = Convert.ToInt32(rawPassport.monthValid.Data); day = Convert.ToInt32(rawPassport.dayValid.Data); passport.ValidTill = new DateTime(year, month, day); passport.Description = rawPassport.note.Data; passport.Citizen = countryList.Find(item => item.Name == rawPassport.citizen.Data); passport.CountryOfEmmitation = countryList.Find(item => item.Name == rawPassport.emmitated.Data); passport.Save(); } rawPassport.IsHandled = true; }