Esempio n. 1
0
 public RoomTypesController(
     IRoomTypesService roomTypesService,
     ICloudinaryService cloudinaryService)
 {
     this.roomTypesService  = roomTypesService;
     this.cloudinaryService = cloudinaryService;
 }
Esempio n. 2
0
 public RoomsController(
     IRoomsService roomsService,
     IRoomTypesService roomTypesService)
 {
     this.roomsService     = roomsService;
     this.roomTypesService = roomTypesService;
 }
 public RoomsController(
     IRoomsService roomsService,
     IRoomTypesService roomTypesService,
     UserManager <ApplicationUser> userManager)
 {
     this.roomsService     = roomsService;
     this.roomTypesService = roomTypesService;
     this.userManager      = userManager;
 }
Esempio n. 4
0
 public ReservedRoomsViewComponent(
     IReservationsService reservationsService,
     IRoomsService roomsService,
     IRoomTypesService roomTypesService)
 {
     this.reservationsService = reservationsService;
     this.roomsService        = roomsService;
     this.roomTypesService    = roomTypesService;
 }
Esempio n. 5
0
 public CalendarController(
     IRoomsService roomsService,
     IRoomTypesService roomTypesService,
     IReservationRoomsService reservationRoomsService,
     IReservationsService reservationsService,
     UserManager <HotelUser> userManager)
 {
     this.roomsService            = roomsService;
     this.roomTypesService        = roomTypesService;
     this.reservationRoomsService = reservationRoomsService;
     this.reservationsService     = reservationsService;
     this.userManager             = userManager;
 }
 public AccommodationsController(
     UserManager <HotelUser> userManager,
     IRoomsService roomsService,
     IReservationsService reservationsService,
     IRoomTypesService roomTypesService,
     IReservationStatusesService reservationStatusesService,
     IPaymentTypesService paymentTypesService,
     IReservationRoomsService reservationRoomsService,
     IEmailSender emailSender)
 {
     this.userManager                = userManager;
     this.roomsService               = roomsService;
     this.reservationsService        = reservationsService;
     this.roomTypesService           = roomTypesService;
     this.reservationStatusesService = reservationStatusesService;
     this.paymentTypesService        = paymentTypesService;
     this.reservationRoomsService    = reservationRoomsService;
     this.emailSender                = emailSender;
 }
        private static async Task SeedRoomTypesAsync(
            ICloudinaryService cloudinaryService,
            IRoomTypesService roomTypesService,
            IWebHostEnvironment env)
        {
            var roomTypes = new AddRoomTypeInputModel[]
            {
                new AddRoomTypeInputModel
                {
                    Name           = "Single room",
                    Price          = 100,
                    CapacityAdults = 1,
                    CapacityKids   = 0,
                    Image          = "pictures/single-room.jpg",
                    Description    = @"Suitable for one adult; LCD TV with cable TV;
Free Wi-Fi access; Individually controlled air conditioning system; 
Separate bathroom and toilet; Non-smoking room; Telephone Hair dryer;",
                },
                new AddRoomTypeInputModel
                {
                    Name           = "Double room",
                    Price          = 150,
                    CapacityAdults = 2,
                    CapacityKids   = 1,
                    Image          = "pictures/double room.jpg",
                    Description    = @"Panoramic window room; Suitable for two adults; 
Individually controlled air conditioning system; LCD TV with cable television; 
Free Wi-Fi Separate beds; Separate bathroom and toilet; Non-smoking room; 
Mini bar; Telephone Hair dryer;",
                },
                new AddRoomTypeInputModel
                {
                    Name           = "Studio",
                    Price          = 200,
                    CapacityAdults = 3,
                    CapacityKids   = 1,
                    Image          = "pictures/club-floor-room.jpg",
                    Description    = @"Each of the spacious studios has a unique vision and interior.
Some of the studios have terraces with wonderful views, as well as baths in the bathrooms. 
The studios at the hotel are equipped with bedrooms, a dressing table, 
a living room with a sofa, armchairs and a coffee table, and the equipment 
includes multi split air conditioners, digital TV, telephone, 
mini bar and wireless internet. Each of the studios bathrooms is supplied with
healing mineral water.",
                },
                new AddRoomTypeInputModel
                {
                    Name           = "Apartment",
                    Price          = 250,
                    CapacityAdults = 4,
                    CapacityKids   = 1,
                    Image          = "pictures/suits.jpg",
                    Description    = @"Stylishly furnished apartments with an area of ​​90 sq.m. consisting
of a separate living and sleeping area and an extra spacious terrace, 
revealing a splendid panoramic view of the mountain.",
                },
            };

            foreach (var type in roomTypes)
            {
                var path = env.WebRootFileProvider.GetFileInfo(type.Image)?.PhysicalPath;

                using (var stream = File.OpenRead(path))
                {
                    var file = new FormFile(stream, 0, stream.Length, null, Path.GetFileName(stream.Name))
                    {
                        Headers     = new HeaderDictionary(),
                        ContentType = "image/jpg",
                    };

                    type.RoomImage = file;

                    var photoUrl = await cloudinaryService.UploadPhotoAsync(
                        type.RoomImage,
                        $"Room - {type.Name}",
                        "Hotel_room_types_photos");

                    type.Image = photoUrl;
                }

                RoomType roomType = AutoMapperConfig.MapperInstance.Map <RoomType>(type);

                await roomTypesService.AddRoomTypeAsync(roomType);
            }
        }