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();
        }
Beispiel #2
0
 public DefaultBookingService(
     HotelApiContext context,
     IDateLogicService dateLogicService)
 {
     _context          = context;
     _dateLogicService = dateLogicService;
 }
Beispiel #3
0
        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 BookingService(
     MonkeyAPIContext context,
     IDateLogicService dateLogicService)
 {
     _context          = context;
     _dateLogicService = dateLogicService;
 }
Beispiel #5
0
 public RoomsController(IRoomService roomService, IOpeningService openingService, IOptions <PagingOptions> defaultPagingOptionsWrapper, IDateLogicService dateLogicService, IBookingService bookingService)
 {
     _roomService          = roomService;
     _openingService       = openingService;
     _dateLogicService     = dateLogicService;
     _bookingService       = bookingService;
     _defaultPagingOptions = defaultPagingOptionsWrapper.Value;
 }
 public DefaultBookingService(
     HotelApiContext context,
     IDateLogicService dateLogicService,
     UserManager <UserEntity> userManager)
 {
     _context          = context;
     _dateLogicService = dateLogicService;
     _userManager      = userManager;
 }
 public DefaultOpeningService(
     HotelApiDbContext context,
     IDateLogicService dateLogicService,
     IMapper mapper)
 {
     _context          = context;
     _dateLogicService = dateLogicService;
     _mapper           = mapper;
 }
Beispiel #8
0
 public DefaultOpeningService(
     HotelApiDbContext context,
     IDateLogicService dateLogicService,
     IConfigurationProvider mappingConfiguration)
 {
     _context              = context;
     _dateLogicService     = dateLogicService;
     _mappingConfiguration = mappingConfiguration;
 }
Beispiel #9
0
 public RoomsController(
     IRoomService roomService,
     IOpeningService openingService,
     IDateLogicService dateLogicService,
     IOptions <PagingOptions> defaultPagingOptions)
 {
     _roomService          = roomService;
     _openingService       = openingService;
     _dateLogicService     = dateLogicService;
     _defaultPagingOptions = defaultPagingOptions.Value;
 }
 public DefaultBookingService(
     HotelApiDbContext context,
     IDateLogicService dateLogicService,
     IConfigurationProvider mappingConfiguration,
     UserManager <UserEntity> userManager)
 {
     _context              = context;
     _dateLogicService     = dateLogicService;
     _mappingConfiguration = mappingConfiguration;
     _userManager          = userManager;
 }
Beispiel #11
0
 public RoomsController(
     IRoomService roomService,
     IOpeningService openingService,
     IOptions <PagingOptions> defaultPagingOptions,
     IDateLogicService dateLogicService,
     IBookingService bookingService)
 {
     this.roomService          = roomService;
     this.openingService       = openingService;
     this.dateLogicService     = dateLogicService;
     this.bookingService       = bookingService;
     this.defaultPagingOptions = defaultPagingOptions.Value;
 }
 public RoomsController(
     IRoomService roomService,
     IOpeningService openingService,
     IDateLogicService dateLogicService,
     IBookingService bookingService,
     IOptions <PagingOptions> pagingOptionsAccessor)
 {
     _roomService          = roomService;
     _openingService       = openingService;
     _dateLogicService     = dateLogicService;
     _bookingService       = bookingService;
     _defaultPagingOptions = pagingOptionsAccessor.Value;
 }
        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();
        }
Beispiel #15
0
        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();
        }
Beispiel #16
0
        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 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();
        }
 public DefaultOpeningService(UppsalaApiContext context, IDateLogicService dateLogicService)
 {
     _context          = context;
     _dateLogicService = dateLogicService;
 }