public void TestInsert1() { var db = new AdventureWorksDB(); var person = db.People.First(); Assert.IsNotNull(person); Assert.IsNotNull(person.BusinessEntityId); person = new Entities.Person(); Assert.IsNull(person.BusinessEntityId); person.PersonType = "GC"; person.NameStyle = false; person.FirstName = "Rick"; person.LastName = "Drizin"; person.EmailPromotion = 0; db.People.Add(person); int savedRecords = db.SaveChanges(); Assert.AreEqual(savedRecords, 1); Assert.IsNotNull(person.BusinessEntityId); var person2 = new AdventureWorksDB().Query <Entities.Person>("SELECT * FROM [Person].[Person] WHERE [BusinessEntityID]=@BusinessEntityID", new { person.BusinessEntityId }).Single(); Assert.IsNotNull(person2); Assert.AreEqual(person.FirstName, person2.FirstName); Assert.AreEqual(person.BusinessEntityId, person2.BusinessEntityId); }
public async Task Handle_CustomerExist_AddIndividualCustomerEmailAddress( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, AddIndividualCustomerEmailAddressCommandHandler sut, Entities.Person person, string accountNumber ) { //Arrange var command = new AddIndividualCustomerEmailAddressCommand { AccountNumber = accountNumber, EmailAddress = EmailAddress.Create("*****@*****.**").Value }; //Act customerRepoMock.Setup(_ => _.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() ) ) .ReturnsAsync(new Entities.IndividualCustomer(person)); var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.IndividualCustomer>(), It.IsAny <CancellationToken>() )); }
public async Task Handle_CustomerExist_AddIndividualCustomerPhone( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, AddIndividualCustomerPhoneCommandHandler sut, AddIndividualCustomerPhoneCommand command, Entities.Person person ) { //Act customerRepoMock.Setup(_ => _.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() ) ) .ReturnsAsync(new Entities.IndividualCustomer(person)); var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.IndividualCustomer>(), It.IsAny <CancellationToken>() )); }
public static Entities.Log validRules(Entities.Person driver, Entities.Person passenger) { if ((driver.JobType == JobType.Policial && passenger.JobType == JobType.Presidiario) || (driver.JobType == JobType.Policial && passenger.JobType == JobType.Piloto || passenger.JobType == JobType.ChefeTripulacao)) { return(Helpers.LogHelper.saveLog(true, driver, passenger)); } else if ((driver.JobType == JobType.Piloto && passenger.JobType == JobType.Oficial) || (driver.JobType == JobType.Piloto && passenger.JobType == JobType.ChefeTripulacao || passenger.JobType == JobType.Policial)) { return(Helpers.LogHelper.saveLog(true, driver, passenger)); } else if ((driver.JobType == JobType.ChefeTripulacao && passenger.JobType == JobType.Comissaria) || (driver.JobType == JobType.ChefeTripulacao && passenger.JobType == JobType.Policial || passenger.JobType == JobType.Piloto)) { return(Helpers.LogHelper.saveLog(true, driver, passenger)); } else { return new Entities.Log { isValid = false } }; }
public void Handle_EmailAddressDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, DeleteIndividualCustomerEmailAddressCommandHandler sut, Entities.Person person, string accountNumber ) { //Arrange var command = new DeleteIndividualCustomerEmailAddressCommand { AccountNumber = accountNumber, EmailAddress = EmailAddress.Create("*****@*****.**").Value }; customerRepoMock.Setup(_ => _.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() ) ) .ReturnsAsync(new Entities.IndividualCustomer(person)); //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'emailAddress')"); }
internal static Entities.Person ToEntity(Person person, MintPlayerContext mintplayer_context) { if (person == null) { return(null); } var entity_person = new Entities.Person { Id = person.Id, FirstName = person.FirstName, LastName = person.LastName, Born = person.Born, Died = person.Died }; #region Media entity_person.Media = person.Media.Select(m => { var medium = MediumRepository.ToEntity(m, mintplayer_context); medium.Subject = entity_person; return(medium); }).ToList(); #endregion #region Tags if (person.Tags != null) { entity_person.Tags = person.Tags.Select(t => { var tag = mintplayer_context.Tags.Find(t.Id); return(new Entities.SubjectTag(entity_person, tag)); }).ToList(); } #endregion return(entity_person); }
public async Task Handle_ExistingCustomerAndAddress_DeleteCustomerAddress( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, Entities.Person person, DeleteIndividualCustomerPhoneCommandHandler sut, DeleteIndividualCustomerPhoneCommand command ) { //Arrange person.AddPhoneNumber( new Entities.PersonPhone( command.Phone.PhoneNumberType, command.Phone.PhoneNumber ) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(new Entities.IndividualCustomer(person)); //Act var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.IndividualCustomer>(), It.IsAny <CancellationToken>() )); }
public void Update(Entities.Person person) { if (personList.Contains(person)) { personList.Remove(person); } personList.Add(person); }
public void AssociateWith(Entities.Person person) { Id = person.Id; Name = person.Name; Lastname = person.Lastname; Group = person.Group; APIPersonId = person.APIPersonId; }
public void AssociateWith(Entities.Person person) { Id = person.Id; Fullname = person.Fullname; Email = person.Email; Group = person.Group; APIPersonId = person.APIPersonId; }
public Person(Entities.Person customer) : base(customer) { FirstName = customer.FirstName; LastName = customer.LastName; Cpf = customer.Cpf; Rg = customer.Rg.AsString(""); BirthDate = customer.BirthDate; Gender = customer.Gender; }
public void Add(Entities.Person person) { int?newId = null; if (personList.Count > 0) { newId = personList.Max(x => x.Id) + 1; } person.Id = newId.GetValueOrDefault(1); personList.Add(person); }
public static Entities.Log saveLog(bool valid, Entities.Person driver, Entities.Person passenger) { return(new Entities.Log { Message = $"A viagem ate o aviao com o SmartForTo foi dirigido pelo {driver.JobType} {driver.Name.ToUpper()}, " + $"eo PASSAGEIRO foi o {passenger.JobType} {passenger.Name.ToUpper()}" + $" O {passenger.Name.ToUpper()} ficou no aviao e o {driver.Name.ToUpper()} voltou dirigindo para o embarque.", isValid = valid }); return(null); }
public async Task Handle_CustomerAndContactExist_UpdateStoreCustomerContact( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, Entities.StoreCustomer customer, UpdateStoreCustomerContactCommandHandler sut, Entities.Person contactPerson, string accountNumber, string contactType ) { //Arrange var command = new UpdateStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto> { new EmailAddressDto { EmailAddress = EmailAddress.Create("*****@*****.**").Value } } } } }; customer.AddContact( new Entities.StoreCustomerContact( command.CustomerContact.ContactType, contactPerson ) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetStoreCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(customer); //Act var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.StoreCustomer>(), It.IsAny <CancellationToken>() )); }
internal static Dtos.Person ToDto(Entities.Person person) { if (person == null) { return(null); } return(new Dtos.Person { Id = person.Id, FirstName = person.FirstName, LastName = person.LastName }); }
private Entities.Person MapJsonPerson(int jsonPersonId, Models.InputJson.Json inputJson) { Models.Person jsonPerson = inputJson.Persons.First(x => x.Id == jsonPersonId); Entities.Person entityPerson = new Entities.Person { Id = jsonPersonId, FirstName = jsonPerson.FirstName, LastName = jsonPerson.LastName }; return(entityPerson); }
public static List <Entities.Person> convertToPerson(dynamic range) { var resultPerson = new List <Entities.Person>(); foreach (var person in range) { var properties = person.GetType().GetProperties(); var personRange = new Entities.Person { Name = person.GetType().GetProperty(properties[0].Name).GetValue(person, null), JobType = (Enums.JobType)person.GetType().GetProperty(properties[1].Name).GetValue(person, null) }; resultPerson.Add(personRange); } return(resultPerson); }
public static PersonDto FromEntity(Entities.Person src) { return(new PersonDto { Id = src.Id, FirstName = src.FirstName, LastName = src.LastName, DOB = src.DateOfBirth, DOD = src.DateOfDeath, AvatarUrl = src.AvatarUrl, Interests = src.Interests, Street1 = src.Street1, Street2 = src.Street2, City = src.City, State = src.State, PostalCode = src.PostalCode }); }
internal static Person ToDto(Entities.Person person, bool include_relations, bool include_invisible_media) { if (person == null) { return(null); } if (include_relations) { return(new Person { Id = person.Id, FirstName = person.FirstName, LastName = person.LastName, Born = person.Born, Died = person.Died, Text = person.Text, DateUpdate = person.DateUpdate ?? person.DateInsert, Artists = person.Artists .Select(ap => ArtistRepository.ToDto(ap.Artist, false, include_invisible_media)) .ToList(), Media = person.Media == null ? null : person.Media .Where(medium => medium.Type.Visible | include_invisible_media) .Select(medium => MediumRepository.ToDto(medium, true)) .ToList(), Tags = person.Tags == null ? null : person.Tags .Select(st => TagRepository.ToDto(st.Tag)) .ToList() }); } else { return(new Person { Id = person.Id, FirstName = person.FirstName, LastName = person.LastName, Born = person.Born, Died = person.Died, Text = person.Text, DateUpdate = person.DateUpdate ?? person.DateInsert }); } }
public void AddOrUpdateVisit(Entities.Person person, DateTime dateOfVisit) { if (person == null) { return; } if (!Table.Any(v => v.PersonId == person.Id && DbFunctions.DiffDays(v.Date, dateOfVisit) == 0)) { person.Visits.Add(new Visit { Date = dateOfVisit, NbPasses = 1 }); } else { person.Visits.Last().NbPasses++; } }
static void Main(string[] args) { var weko = new Entities.Person { FirstName = "Wekoslav", LastName = "Stefanovski", Age = 0x26, Address = "Kisela Voda, Skopje" }; Type personType = weko.GetType(); var props = personType.GetProperties(); personType.GetMembers(); Console.WriteLine(weko); weko.SetProperty("FirstName", "Weko"); Console.WriteLine(weko); }
public void Handle_PhoneNumberDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, DeleteIndividualCustomerPhoneCommandHandler sut, DeleteIndividualCustomerPhoneCommand command, Entities.Person person ) { //Arrange customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(new Entities.IndividualCustomer(person)); //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'phone')"); }
public RegisterConsistentValidation(Entities.Person person) { BaseValidation = new BaseValidation(); var nameSpecification = new NameIsNotNullSpecification(); BaseValidation.AddSpecification("Name-Specification", nameSpecification.IsSatisfyedBy(person), "Name is null."); var usernameSpecification = new UsernameIsNotNullSpecification(); BaseValidation.AddSpecification("Username-Specification", usernameSpecification.IsSatisfyedBy(person.Credential), "Username is null."); var passwordSpecification = new PasswordIsNotNullSpecification(); BaseValidation.AddSpecification("Password-Specification", passwordSpecification.IsSatisfyedBy(person.Credential), "Password is null."); }
/// <summary> /// Creates a new Auth token setting the client and the person from client to the corresponding values. /// </summary> /// <param name="client"></param> /// <param name="newPersonFromClient"></param> public AuthorizationToken(Entities.Person client, Entities.Person newPersonFromClient) { this.Client = client; this.PersonFromClient = newPersonFromClient; }
public async Task <List <Person> > Run(string fileContents, SortType sortType, OrderType orderType) { var lines = fileContents.Split(Environment.NewLine); //Print the query output on console // Execute the query and write out the new file. var peopleService = new PersonService(); var people = new List <Person>(); foreach (var line in lines) { people.Add(new Person(line)); } var sortedNames = new List <Person>(); if (sortType == SortType.firstname) { if (orderType == OrderType.ascending) { INameSorter namesorter = new NameSorterAscending(x => x.FullName); sortedNames = namesorter.Sort(people); } else if (orderType == OrderType.descending) { INameSorter namesorter = new NameSorterDecending(x => x.FullName); sortedNames = namesorter.Sort(people); } } else if (sortType == SortType.lastname) { if (orderType == OrderType.ascending) { INameSorter namesorter = new NameSorterAscending(x => x.Surname); sortedNames = namesorter.Sort(people); } else if (orderType == OrderType.descending) { INameSorter namesorter = new NameSorterDecending(x => x.Surname); sortedNames = namesorter.Sort(people); } } foreach (var person in sortedNames) { var cacheResult = _cache.Get <GenderizeResult>(person.FirstName); if (cacheResult == null) { var jsonResponse = await client.GetGender(person.FirstName); var genderObject = JsonConvert.DeserializeObject <GenderizeResult>(jsonResponse); if (genderObject == null) { } person.Gender = genderObject.gender; var saveCache = _cache.Set(person.FirstName, genderObject); } else { person.Gender = cacheResult.gender; } } var sortedLines = PersonService.GetFullNames(sortedNames); File.WriteAllLines(@"sorted-names-list.txt", sortedLines); foreach (var person in sortedNames) { var personfullnames = new Entities.Person() { FirstName = person.FirstName, Surname = person.Surname, Gender = person.Gender, FullName = person.FirstName + " " + person.Surname, }; var existingRecords = personRepository.GetByName(personfullnames.FirstName, personfullnames.Surname, personfullnames.Gender, personfullnames.FullName).ToList(); if (existingRecords.Count > 0) { } else { personRepository.Add(personfullnames); personRepository.SaveAll(); } } sortedLines.ForEach(line => logger.LogInformation(line)); Console.WriteLine("Sorted names are written to file. Press any key to exit"); return(sortedNames); }
public bool IsSatisfyedBy(Entities.Person entity) { return(!String.IsNullOrEmpty(entity.Name)); }
/// <summary> /// Resolves a list of permission groups into a resolved permission for the given person. /// </summary> /// <param name="person"></param> /// <param name="client"></param> /// <returns></returns> public static ResolvedPermissions ResolvePermissions(this Entities.Person client, Entities.Person person) { //Ensure that the client isn't null. if (client == null) { throw new ArgumentException("The client may not be null"); } var resolvedPermissions = new ResolvedPermissions() { TimeResolved = DateTime.UtcNow, ClientId = client.Id.ToString(), PersonId = person?.Id.ToString() }; //Let's do some work here to get either the permission groups or the permission group names and turn them into groups. List <PermissionGroup> groups = client.PermissionGroups; if ((groups == null || !groups.Any()) && client.PermissionGroupNames.Any()) { groups = PermissionGroup.AllPermissionGroups.Where(x => client.PermissionGroupNames.Contains(x.GroupName, StringComparer.CurrentCultureIgnoreCase)).ToList(); } if (groups == null) { groups = PermissionGroup.AllPermissionGroups.Where(x => x.IsDefault).ToList(); } else { groups.AddRange(PermissionGroup.AllPermissionGroups.Where(x => x.IsDefault)); } //Now we need to start iterating. foreach (var group in groups) { //Add the names to the permission group names so the client knows who permission groups we used. resolvedPermissions.PermissionGroupNames.Add(group.GroupName); //Add the editable permission groups. foreach (var editPermissionGroup in group.GroupsCanEditMembershipOf) { if (!resolvedPermissions.EditablePermissionGroups.Contains(editPermissionGroup)) { resolvedPermissions.EditablePermissionGroups.Add(editPermissionGroup); } } //And the accessible submodules. foreach (var accessibleSubmodule in group.AccessibleSubModules) { if (!resolvedPermissions.AccessibleSubmodules.Contains(accessibleSubmodule)) { resolvedPermissions.AccessibleSubmodules.Add(accessibleSubmodule); } } foreach (var coc in group.ChainsOfCommandParts) { //First the highest levels. if (resolvedPermissions.HighestLevels[coc.ChainOfCommand] < group.AccessLevel) { resolvedPermissions.HighestLevels[coc.ChainOfCommand] = group.AccessLevel; } //Now let's go through this coc and the types and see who passes the tests. Editable first. coc.PropertyGroups .Where(x => x.AccessCategory == AccessCategories.Edit && x.Disjunctions .All(y => y.Rules .Any(z => z.AuthorizationOperation(new AuthorizationToken(client, person))))) .SelectMany(x => x.Properties) .ToList() .ForEach(x => { if (resolvedPermissions.EditableFields.TryGetValue(x.DeclaringType.Name, out List <string> fields)) { if (!fields.Contains(x.Name)) { fields.Add(x.Name); } } else { resolvedPermissions.EditableFields[x.DeclaringType.Name] = new List <string> { x.Name }; } }); //Now let's go through this coc and the types and see who passes the tests. Now returnable! coc.PropertyGroups .Where(x => x.AccessCategory == AccessCategories.Return && x.Disjunctions .All(y => y.Rules .Any(z => z.AuthorizationOperation(new AuthorizationToken(client, person))))) .SelectMany(x => x.Properties) .ToList() .ForEach(x => { if (resolvedPermissions.ReturnableFields.TryGetValue(x.DeclaringType.Name, out List <string> fields)) { if (!fields.Contains(x.Name)) { fields.Add(x.Name); } } else { resolvedPermissions.ReturnableFields[x.DeclaringType.Name] = new List <string> { x.Name }; } }); coc.PropertyGroups .Where(x => x.AccessCategory == AccessCategories.Return && (!x.Disjunctions.Any() || x.Disjunctions.All(y => y.Rules.All(z => z is Rules.IfInChainOfCommandRule)))) .SelectMany(x => x.Properties) .ToList() .ForEach(x => { if (resolvedPermissions.PrivelegedReturnableFields.TryGetValue(group.AccessLevel, out Dictionary <string, List <string> > fieldsByType)) { if (fieldsByType.TryGetValue(x.DeclaringType.Name, out List <string> fields)) { if (!fields.Contains(x.Name)) { fields.Add(x.Name); } } else { fieldsByType[x.DeclaringType.Name] = new List <string> { x.Name }; } } else { resolvedPermissions.PrivelegedReturnableFields[group.AccessLevel] = new Dictionary <string, List <string> > { { x.DeclaringType.Name, new List <string> { x.Name } } }; } }); } } //Now we need to copy the fields to the level beneath them because of this assumption: //Any field I can return at the command level, I can return at the division level. foreach (var pair in resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Command]) { if (resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Department].TryGetValue(pair.Key, out List <string> fields)) { fields = fields.Concat(pair.Value).Distinct().ToList(); } else { resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Department] = new Dictionary <string, List <string> > { { pair.Key, pair.Value } }; } } foreach (var pair in resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Department]) { if (resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Division].TryGetValue(pair.Key, out List <string> fields)) { fields = fields.Concat(pair.Value).Distinct().ToList(); } else { resolvedPermissions.PrivelegedReturnableFields[ChainOfCommandLevels.Division] = new Dictionary <string, List <string> > { { pair.Key, pair.Value } }; } } //Now let's do the chain of command determination. If we're talking about the same person, then the answer is no. foreach (var highestLevel in resolvedPermissions.HighestLevels) { if (person == null) { resolvedPermissions.IsInChainOfCommand[highestLevel.Key] = false; } else { switch (highestLevel.Value) { case ChainOfCommandLevels.Command: { resolvedPermissions.IsInChainOfCommand[highestLevel.Key] = client.IsInSameCommandAs(person); break; } case ChainOfCommandLevels.Department: { resolvedPermissions.IsInChainOfCommand[highestLevel.Key] = client.IsInSameDepartmentAs(person); break; } case ChainOfCommandLevels.Division: { resolvedPermissions.IsInChainOfCommand[highestLevel.Key] = client.IsInSameDivisionAs(person); break; } case ChainOfCommandLevels.Self: case ChainOfCommandLevels.None: { resolvedPermissions.IsInChainOfCommand[highestLevel.Key] = false; break; } default: { throw new NotImplementedException("In the switch between levels in the CoC determinations in Resolve()."); } } } } return(resolvedPermissions); }
public Entities.Customer Transfer(Account account = null) { Entities.Customer customer; if (this.Type == CustomerType.Person) { customer = new Entities.Person() { FirstName = ((Person)this).FirstName, LastName = ((Person)this).LastName, Cpf = ((Person)this).Cpf, Rg = ((Person)this).Rg, BirthDate = ((Person)this).BirthDate, Gender = ((Person)this).Gender.IsNullorEmpty() ? null : ((Person)this).Gender, Name = string.Format("{0} {1}", ((Person)this).FirstName, ((Person)this).LastName) }; if (!account.IsNull()) { ((Entities.Person)customer).Cpf = account.Document; } } else { customer = new Entities.Company() { CompanyName = ((Company)this).CompanyName, TradeName = ((Company)this).TradeName, Cnpj = ((Company)this).Cnpj, Ie = ((Company)this).Ie, Im = ((Company)this).Im, Name = ((Company)this).CompanyName }; if (!account.IsNull()) { ((Entities.Company)customer).Cnpj = account.Document; } } customer.Type = this.Type; customer.Addresses = !this.Addresses.IsNull() ? this.Addresses.Select(a => a.Transfer()).ToList() : new List <AddressCustomer>(); customer.NewsLetter = this.NewsLetter ?? false; customer.Status = this.Status; if (!account.IsNull()) { customer.Email = account.Email; } if (!account.Code.IsNull()) { customer.Account = new Entities.Account() { Code = account.Code } } ; return(customer); } }
public static dynamic rulesBording(List <Entities.Person> rangeTreated) { var quantityPiloto = 0; var quantityChef = 0; var personBording = new List <Entities.Person>(); var listString = new List <string>(); if (rangeTreated.Count == 1) { listString.Add($"O {rangeTreated[0].Name.ToUpper()} foi o ultimo a embarcar."); personBording.Add(rangeTreated[0]); } var driver = new Entities.Person(); var passenger = new Entities.Person(); foreach (var people in rangeTreated) { if (people.drive && string.IsNullOrEmpty(driver.Name)) { driver = people; } else if ((!people.drive && passenger.JobType != JobType.ChefeTripulacao && passenger.JobType != JobType.Policial && passenger.JobType != JobType.Piloto) || (rangeTreated.Count == 4 && people.JobType == JobType.ChefeTripulacao)) { passenger = people; } else { continue; } if (driver.Name != null && passenger.Name != null) { var validRule = Helpers.BordingHelper.validRules(driver: driver, passenger: passenger); if (validRule.isValid) { listString.Add(validRule.Message); personBording.Add(passenger); passenger = new Entities.Person(); if (driver.JobType == Enums.JobType.Policial) { passenger = driver; driver = new Entities.Person(); } if (driver.JobType == Enums.JobType.Piloto) { quantityPiloto++; } if (driver.JobType == Enums.JobType.ChefeTripulacao) { quantityChef++; } if (quantityChef >= 2 || quantityPiloto >= 3) { passenger = driver; driver = new Entities.Person(); } } else { continue; } } else { continue; } } return(new { peopleBoarded = personBording, listWrite = listString }); }