public void Test_SqlServer() { CreateUnitOfWork_SqlServer(); var uow = serviceProvider.GetService <IUnitOfWork>(); var repo = serviceProvider.GetService <BsDataRepository>(); uow.RunInTransaction(() => { var country = new CountryModel { Name = "Italy" }; repo.CreateCountry(country); var person1 = new PersonModel { Name = "Fabio", Lastname = "Cavallari", Age = 40, ContactDate = new DateTime(2020, 9, 2), Description = "Simply me", Photo = new byte[] { 12, 34, 76, 250, 1, 0, 44, 2 } }; repo.CreatePerson(person1); var person1Addresses = new List <AddressModel>(); person1Addresses.Add(new AddressModel { Country = country, PostalCode = "12345", StreetName = "Via liguria, 34/12", Person = person1 }); person1Addresses.Add(new AddressModel { Country = country, PostalCode = "6789", StreetName = "Corso del popolo, 112", Person = person1 }); person1Addresses.ForEach(a => repo.CreateAddress(a)); person1.Addresses = person1Addresses; repo.UpdatePerson(person1); var person2 = new PersonModel { Name = "Pinco", Lastname = "Pallino", Age = 28, ContactDate = new DateTime(2018, 9, 2), Description = "Simply no one", Photo = new byte[] { 60, 22, 115, 250, 20, 7, 44, 3 } }; repo.CreatePerson(person2); var person2Addresses = new List <AddressModel>(); person2Addresses.Add(new AddressModel { Country = country, PostalCode = "666", StreetName = "Via carlo rosselli, 2", Person = person2 }); person2Addresses.Add(new AddressModel { Country = country, PostalCode = "321", StreetName = "Corso francia, 1112", Person = person2 }); person2Addresses.ForEach(a => repo.CreateAddress(a)); person2.Addresses = person2Addresses; repo.UpdatePerson(person2); var rooms = new List <RoomModel>(); rooms.Add(new RoomModel { Name = "RECEPTION", Persons = new PersonModel[] { person1, person2 } }); rooms.Add(new RoomModel { Name = "ADMINISTRATION", Persons = new PersonModel[] { person2 } }); rooms.Add(new RoomModel { Name = "ICT", Persons = new PersonModel[] { person1 } }); rooms.ForEach(a => repo.CreateRoom(a)); }); var persons = repo.GetPersons(); var address = repo.GetAddresses(); var rooms = repo.GetRooms(); Assert.IsNotNull(persons.FirstOrDefault().Id); }
public void CreateCountry(CountryModel entity) { Create(entity); }