public static int GetAppointmentId(StudioDbContext context, int?serviceId, int?employeeId, string userId) { Appointment appointment = new Appointment { ReservationDate = new DateTime(2021, 09, 09), TimeBlockHelper = GConst.ValidHour, }; if (serviceId != null) { appointment.ServiceId = serviceId.Value; } if (employeeId != null) { appointment.EmployeeId = employeeId.Value; } if (userId != null) { appointment.UserId = userId; } appointment.ReservationTime = DateTime.Parse(appointment.TimeBlockHelper); context.Appointments.Add(appointment); context.SaveChanges(); var appointmentId = context.Appointments.SingleOrDefault(x => x.TimeBlockHelper == GConst.ValidHour).Id; return(appointmentId); }
public static int GetAddressId(StudioDbContext context, int?cityId) { var inputAddressData = new InputAddressData { Street = GConst.ValidName, Number = GConst.ValidAddressNumber }; Address address = new Address { AddressFormat = AddressFormat.For(inputAddressData) }; if (cityId != null) { address = new Address { AddressFormat = AddressFormat.For(inputAddressData), CityId = cityId.Value }; } context.Addresses.Add(address); context.SaveChangesAsync(); var addressId = context.Addresses.SingleOrDefault(x => x.AddressFormat.Street == GConst.ValidName).Id; return(addressId); }
public static int GetLocationId(StudioDbContext context, int?clientId, int?addressId) { Location location = new Location { Name = GConst.ValidName, StartHour = GConst.ValidStartHour, EndHour = GConst.ValidEndHour, StartDay = Workday.Понеделник, EndDay = Workday.Петък, Slogan = GConst.ValidName, Description = GConst.ValidName }; if (clientId != null) { location.ClientId = clientId.Value; } if (addressId != null) { location.AddressId = addressId.Value; } context.Locations.Add(location); context.SaveChanges(); var locationId = context.Locations.SingleOrDefault(x => x.Name == GConst.ValidName).Id; return(locationId); }
public static void AddAddresses(StudioDbContext context) { InputAddressData addressData = new InputAddressData { Street = "Vasil Levski", Number = "10", Building = "3G", Entrance = "B" }; var cityId = CommandArrangeHelper.GetCityId(context, null); var addresses = new List <Address> { new Address { Id = 1, AddressFormat = (AddressFormat)addressData, Longitude = 40.35M, Latitude = 56.23M, CityId = cityId }, new Address { Id = 2, AddressFormat = (AddressFormat)addressData, Longitude = 40.35M, Latitude = 56.23M, CityId = cityId }, new Address { Id = 3, AddressFormat = (AddressFormat)addressData, Longitude = 40.35M, Latitude = 56.23M, CityId = cityId } }; context.Addresses.AddRange(addresses); context.SaveChanges(); }
public static void AddLocationIndustry(StudioDbContext context, int industryId, int locationId) { var locationIndustry = new LocationIndustry { IndustryId = industryId, LocationId = locationId }; context.LocationIndustries.Add(locationIndustry); context.SaveChanges(); }
public static void AddEmployeeServices(StudioDbContext context) { var employeeId = CommandArrangeHelper.GetEmployeeId(context, null); var serviceId = CommandArrangeHelper.GetServiceId(context, null); var employeeService = new EmployeeService { EmployeeId = employeeId, ServiceId = serviceId, Price = 40.00M, DurationInMinutes = "30" }; context.EmployeeServices.AddRange(employeeService); context.SaveChanges(); }
public static void AddLocationIndustries(StudioDbContext context) { var locationId = CommandArrangeHelper.GetLocationId(context, null, null); var industryId = CommandArrangeHelper.GetIndustryId(context); var locationIndustry = new LocationIndustry { LocationId = locationId, IndustryId = industryId, Description = "Good!" }; context.LocationIndustries.Add(locationIndustry); context.SaveChanges(); }
public static void AddEmployeeService(StudioDbContext context, int serviceId, int employeeId) { var employeeService = new EmployeeService { ServiceId = serviceId, EmployeeId = employeeId, DurationInMinutes = GConst.ValidServiceDuration }; context.EmployeeServices.Add(employeeService); context.SaveChanges(); }
public static StudioDbContext Create() { var options = new DbContextOptionsBuilder <StudioDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new StudioDbContext(options); context.Database.EnsureCreated(); return(context); }
public StudioDbContext GetDbContext() { var builder = new DbContextOptionsBuilder <StudioDbContext>(); builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var dbContext = new StudioDbContext(builder.Options); dbContext.Database.EnsureCreated(); return(dbContext); }
public static int GetIndustryId(StudioDbContext context) { var industry = new Industry { Name = GConst.ValidName, Possition = GConst.ValidName }; context.Industries.Add(industry); context.SaveChanges(); var industryId = context.Industries.SingleOrDefault(x => x.Name == GConst.ValidName).Id; return(industryId); }
public static int GetCountryId(StudioDbContext context) { var country = new Country { Name = GConst.ValidName }; context.Countries.Add(country); context.SaveChanges(); var countryId = context.Countries.SingleOrDefault(x => x.Name == GConst.ValidName).Id; return(countryId); }
public static int GetClientId(StudioDbContext context) { var client = new Client { CompanyName = GConst.ValidName }; context.Clients.Add(client); context.SaveChanges(); var clientId = context.Clients.SingleOrDefault(x => x.CompanyName == GConst.ValidName).Id; return(clientId); }
public static string GetUserId(StudioDbContext context) { var user = new StudioUser { UserName = GConst.ValidName, Email = GConst.ValidEmail }; context.StudioUsers.Add(user); context.SaveChanges(); var userId = context.StudioUsers.SingleOrDefault(x => x.UserName == GConst.ValidName).Id; return(userId); }
public static int[] GetEmployeeServiceIds(StudioDbContext context) { var ids = new int[2]; var locationId = GetLocationId(context, null, null); var employeeId = GetEmployeeId(context, locationId); var serviceId = GetServiceId(context, null); ids[0] = employeeId; ids[1] = serviceId; AddEmployeeService(context, employeeId, serviceId); return(ids); }
public static int GetCityId(StudioDbContext context, int?countryId) { City city = new City { Name = GConst.ValidName }; if (countryId != null) { city.CountryId = countryId.Value; } context.Cities.Add(city); context.SaveChangesAsync(); var cityId = context.Cities.SingleOrDefault(x => x.Name == GConst.ValidName).Id; return(cityId); }
public static void AddClients(StudioDbContext context) { var clients = new List <Client> { new Client { Id = 1, CompanyName = "Saloon 5", VatNumber = "124556632", Manager = (Manager)"Ivan Petrov", Phone = "+359888444666" }, new Client { Id = 2, CompanyName = "Beauty", VatNumber = "245653958", Manager = (Manager)"Petar Ivanov", Phone = "+359889659656" }, new Client { Id = 3, CompanyName = "Gilly", VatNumber = "BG145856354", Manager = (Manager)"Gosho Petrov", Phone = "+359888656454" }, }; context.Clients.AddRange(clients); context.SaveChanges(); }
public static void AddLocations(StudioDbContext context) { var cityId = CommandArrangeHelper.GetCityId(context, null); var addressId = CommandArrangeHelper.GetAddressId(context, cityId); var clientId = CommandArrangeHelper.GetClientId(context); var locations = new List <Location> { new Location { Id = 1, Name = GConst.ValidName, StartDay = Workday.Понеделник, EndDay = Workday.Петък, StartHour = "9", EndHour = "18", Phone = "0888777666", AddressId = addressId, ClientId = clientId } }; context.Locations.AddRange(locations); context.SaveChanges(); }
public static void AddCountries(StudioDbContext context) { var countries = new List <Country> { new Country { Id = 1, Name = "Bulgaria" }, new Country { Id = 2, Name = "France" }, new Country { Id = 3, Name = "England" }, }; context.Countries.AddRange(countries); context.SaveChanges(); }
public static int GetEmployeeId(StudioDbContext context, int?locationId) { var employee = new Employee { FirstName = GConst.ValidName }; if (locationId != null) { employee.LocationId = locationId.Value; } context.Employees.Add(employee); context.SaveChangesAsync(); var employeeId = context.Employees.SingleOrDefault(x => x.FirstName == GConst.ValidName).Id; return(employeeId); }
public static void AddUsers(StudioDbContext context) { var users = new List <StudioUser> { new StudioUser { Id = Guid.NewGuid().ToString(), Email = "*****@*****.**" }, new StudioUser { Id = Guid.NewGuid().ToString(), Email = "*****@*****.**" }, new StudioUser { Id = Guid.NewGuid().ToString(), Email = "*****@*****.**" }, }; context.StudioUsers.AddRange(users); context.SaveChanges(); }
public static int GetServiceId(StudioDbContext context, int?industryId) { Service service = new Service { Name = GConst.ValidName }; if (industryId != null) { service.IndustryId = industryId.Value; } context.Services.Add(service); context.SaveChangesAsync(); var serviceId = context.Services.SingleOrDefault(x => x.Name == GConst.ValidName).Id; return(serviceId); }
public static void AddIndustries(StudioDbContext context) { var industries = new List <Industry> { new Industry { Id = 1, Name = "Hairstyle", Possition = "Styler" }, new Industry { Id = 2, Name = "Fitness", Possition = "Instructor" }, new Industry { Id = 3, Name = "Massage", Possition = "Мasseur" } }; context.Industries.AddRange(industries); context.SaveChanges(); }
public static void AddEmployees(StudioDbContext context) { var industryId = CommandArrangeHelper.GetIndustryId(context); var serviceId = CommandArrangeHelper.GetServiceId(context, industryId); var addressId = CommandArrangeHelper.GetAddressId(context, null); var locationId = CommandArrangeHelper.GetLocationId(context, null, addressId); var employee = new Employee { Id = 1, FirstName = GConst.ValidName, LastName = GConst.ValidName, LocationId = locationId }; context.Employees.Add(employee); var employeeService = new EmployeeService { ServiceId = serviceId, EmployeeId = employee.Id }; context.EmployeeServices.Add(employeeService); context.SaveChanges(); }
public static void AddCities(StudioDbContext context) { var countryId = CommandArrangeHelper.GetCountryId(context); var cities = new List <City> { new City { Id = 1, Name = "Sofia", CountryId = countryId }, new City { Id = 2, Name = "Varna", CountryId = countryId }, new City { Id = 3, Name = "Burgas", CountryId = countryId }, }; context.Cities.AddRange(cities); context.SaveChanges(); }
public static void AddServices(StudioDbContext context) { var industryId = CommandArrangeHelper.GetIndustryId(context); var services = new List <Service> { new Service { Id = 1, Name = "Hairstyle", IndustryId = industryId }, new Service { Id = 2, Name = "Colormade", IndustryId = industryId }, new Service { Id = 3, Name = "Massage", IndustryId = industryId } }; context.Services.AddRange(services); context.SaveChanges(); }
public static string AddAppointmentes(StudioDbContext context) { var userId = CommandArrangeHelper.GetUserId(context); var employeeId = CommandArrangeHelper.GetEmployeeId(context, null); var serviceId = CommandArrangeHelper.GetServiceId(context, null); var appointments = new List <Appointment> { new Appointment { Id = 1, Comment = "Be Happy!", ReservationDate = new DateTime(2019, 09, 15), TimeBlockHelper = "9", ReservationTime = new DateTime(2019, 09, 15, 9, 0, 0), EmployeeId = employeeId, ServiceId = serviceId, UserId = userId }, new Appointment { Id = 2, Comment = "Be Happy!", ReservationDate = new DateTime(2019, 09, 15), TimeBlockHelper = "9", ReservationTime = new DateTime(2019, 09, 15, 9, 0, 0), EmployeeId = employeeId, ServiceId = serviceId, UserId = userId }, new Appointment { Id = 3, Comment = "Be Happy!", ReservationDate = new DateTime(2019, 09, 15), TimeBlockHelper = "9", ReservationTime = new DateTime(2019, 09, 15, 9, 0, 0), EmployeeId = employeeId, ServiceId = serviceId, UserId = userId } }; context.Appointments.AddRange(appointments); context.SaveChanges(); return(userId); }
public static void InitializeDbForTests(StudioDbContext context) { StudioInitializer.Initialize(context); }
public QueryTestFixture() { context = StudioDBContextFactory.Create(); mapper = AutoMapperFactory.Create(); }
public static void Destroy(StudioDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }