public static void AddTestData(HotelApiContext dbContext, IDateLogicService dateLogicService) { var premium = dbContext.Rooms.Add(new RoomEntity() { Id = Guid.Parse("5c8fbfee-e9e3-4bcc-bdee-643203a30ef9"), Name = "Premium Suite", Rate = 10119 }).Entity; dbContext.Rooms.Add(new RoomEntity() { Id = Guid.Parse("c3b7ed37-e6a9-457c-b1c8-42cc7ba07095"), Name = "Standard", Rate = 23959 }); var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); dbContext.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = premium, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = premium.Rate, }); dbContext.SaveChanges(); }
private static void AddTestData( HotelApiContext context, IDateLogicService dateLogicService) { context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); var oxford = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }).Entity; var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, }); context.SaveChanges(); }
public static async Task AddTestData( HotelApiDbContext context, IDateLogicService dateLogicService, UserManager <UserEntity> userManager) { if (context.Rooms.Any()) { // Already has data return; } context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); var oxford = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }).Entity; var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); var adminUser = userManager.Users .SingleOrDefault(u => u.Email == "*****@*****.**"); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, User = adminUser }); await context.SaveChangesAsync(); }
private static void AddTestData( HotelApiContext context, IDateLogicService dateLogicService, UserManager <UserEntity> userManager) { context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); // checked that data is inserted to database or not var insertedRoom = context.Rooms.FirstOrDefault(c => c.Id == Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08")); if (insertedRoom != null) { return; } var oxford = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }).Entity; var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); var adminUser = userManager.Users .SingleOrDefault(u => u.Email == "*****@*****.**"); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, User = adminUser }); context.SaveChanges(); }
private static void AddTestData( UppsalaApiContext context, IDateLogicService dateLogicService, UserManager <UserEntity> userManager) { var roomA300 = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Lecture Hall A300", Rate = 23959 }).Entity; context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-0a586ae59576"), Name = "Lecture Hall B200", Rate = 10119 }); var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); var adminUser = userManager.Users .SingleOrDefault(u => u.Email == "*****@*****.**"); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = roomA300, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = roomA300.Rate, User = adminUser }); context.SaveChanges(); }
public static async Task AddTestData(HotelApiDbContext context, IDateLogicService dateLogicService) { // Return if already data (probably not test instance) if (context.Rooms.Any()) { return; } var oxford = new RoomEntity { Id = Guid.Parse("33ed08b6-cd8c-4fe1-be31-0ac918a9a054"), Name = "Oxford Suite", Rate = 10119 }; context.Rooms.Add(oxford); context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ce9616dc-55c8-48af-b336-332733350889"), Name = "Driscoll Suite", Rate = 23959 }); var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, }); await context.SaveChangesAsync(); }
public static async Task AddTestDataAsync(HotelApiDbContext context, IDateLogicService dateLogicService) //zabezpecuje seedovanie DB { if (context.Rooms.Any()) { //already has data return; } var oxford = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }).Entity; context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, }); await context.SaveChangesAsync(); }