private static void AddTestData(HotelApiContext context) { context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }); context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); context.SaveChanges(); }
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( HotelApiContext context, IDateLogicService dateLogicService) { 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 }); context.Rooms.Add(new RoomEntity { Id = Guid.NewGuid(), Name = "Cambridge Suite", Rate = 32309 }); 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(); }