public void CreateMissingPerson( string firstName, string lastName, Gender gender, DateTime dateOfBirth, string placeOfBirth, DateTime dateOfDisappearance, string placeOfDisappearance, double height, double weight, Color hairColor, Color eyesColor, string pictureUrl, IEnumerable <int> nationalitiesIds, IEnumerable <int> languagesIds, string allNames, string scarsOrDistinguishingMarks) { this.ValidateMissingPeopleData(firstName, lastName, gender, dateOfBirth, placeOfBirth, dateOfDisappearance, placeOfDisappearance, height, weight, hairColor, eyesColor, pictureUrl, nationalitiesIds, languagesIds); var physicalDescription = new PhysicalDescription { Height = height, Weight = weight, HairColor = hairColor, EyeColor = eyesColor, PictureUrl = pictureUrl, ScarsOrDistinguishingMarks = scarsOrDistinguishingMarks }; var missingPerson = new IdentityParticularsMissing { FirstName = firstName, LastName = lastName, Gender = gender, DateOfBirth = dateOfBirth, PlaceOfBirth = placeOfBirth, DateOfDisappearance = dateOfDisappearance, PlaceOfDisappearance = placeOfDisappearance, AllNames = allNames, PhysicalDescription = physicalDescription }; // add the nationalities and languages to the person AddLanguagesAndCountriesCollections(nationalitiesIds, languagesIds, missingPerson); this.db.IdentityParticularsMissing.Add(missingPerson); this.db.SaveChanges(); }
private IEnumerable <IdentityParticularsMissing> GetMissingPeopleData() { var firstMissingPerson = new IdentityParticularsMissing { Id = 1, FirstName = "Pesho", LastName = "Peshev", DateOfBirth = DateTime.UtcNow, PlaceOfDisappearance = "UK, London" }; var secondMissingPerson = new IdentityParticularsMissing { Id = 2, FirstName = "Ivan", LastName = "Ivanov", DateOfBirth = DateTime.UtcNow, PlaceOfDisappearance = "UK, Liverpool" }; return(new List <IdentityParticularsMissing> { firstMissingPerson, secondMissingPerson }); }
private void AddLanguagesAndCountriesCollections(IEnumerable <int> nationalitiesIds, IEnumerable <int> languagesIds, IdentityParticularsMissing existingPerson) { foreach (var nationalityId in nationalitiesIds) { var countriesNationalities = new CountriesNationalitiesMissing { CountryId = nationalityId, IdentityParticularsMissingId = existingPerson.Id }; existingPerson.Nationalities.Add(countriesNationalities); } foreach (var languageId in languagesIds) { var languageMissing = new LanguagesMissing { LanguageId = languageId, IdentityParticularsMissingId = existingPerson.Id }; existingPerson.SpokenLanguages.Add(languageMissing); } }