private IEnumerable <IdentityParticularsWanted> GetWantedPeopleData() { var firstWantedPerson = new IdentityParticularsWanted { Id = 1, FirstName = "Pesho", LastName = "Peshev", DateOfBirth = DateTime.UtcNow, Reward = 10000 }; var secondWantedPerson = new IdentityParticularsWanted { Id = 2, FirstName = "Ivan", LastName = "Ivanov", DateOfBirth = DateTime.UtcNow, Reward = 50000 }; return(new List <IdentityParticularsWanted> { firstWantedPerson, secondWantedPerson }); }
private void AddLanguagesAndCountriesCollections(IEnumerable <int> nationalitiesIds, IEnumerable <int> languagesIds, IdentityParticularsWanted existingPerson) { foreach (var nationalityId in nationalitiesIds) { var countriesNationalities = new CountriesNationalitiesWanted { CountryId = nationalityId, IdentityParticularsWantedId = existingPerson.Id }; existingPerson.Nationalities.Add(countriesNationalities); } foreach (var languageId in languagesIds) { var languageWanted = new LanguagesWanted { LanguageId = languageId, IdentityParticularsWantedId = existingPerson.Id }; existingPerson.SpokenLanguages.Add(languageWanted); } }
public void CreateWantedPerson( string firstName, string lastName, Gender gender, DateTime dateOfBirth, string placeOfBirth, decimal reward, double height, double weight, Color hairColor, Color eyesColor, string pictureUrl, IEnumerable <int> nationalitiesIds, IEnumerable <int> languagesIds, string allNames = null, string scarsOrDistinguishingMarks = null) { this.ValidateWantedPeopleData(firstName, lastName, gender, dateOfBirth, placeOfBirth, height, weight, hairColor, eyesColor, pictureUrl, nationalitiesIds, languagesIds, reward); var physicalDescription = new PhysicalDescription { Height = height, Weight = weight, HairColor = hairColor, EyeColor = eyesColor, PictureUrl = pictureUrl, ScarsOrDistinguishingMarks = scarsOrDistinguishingMarks }; var wantedPerson = new IdentityParticularsWanted { FirstName = firstName, LastName = lastName, Gender = gender, DateOfBirth = dateOfBirth, PlaceOfBirth = placeOfBirth, AllNames = allNames, PhysicalDescription = physicalDescription, Reward = reward }; foreach (var nationalityId in nationalitiesIds) { var countriesNationalities = new CountriesNationalitiesWanted { CountryId = nationalityId, IdentityParticularsWantedId = wantedPerson.Id }; wantedPerson.Nationalities.Add(countriesNationalities); } foreach (var languageId in languagesIds) { var languageMissing = new LanguagesWanted { LanguageId = languageId, IdentityParticularsWantedId = wantedPerson.Id }; wantedPerson.SpokenLanguages.Add(languageMissing); } this.db.IdentityParticularsWanted.Add(wantedPerson); this.db.SaveChanges(); }