public async Task <IActionResult> Create(HotelInformationViewModel model, string id)
        {
            var hotelId = await this.signalService.CreateAsync(model.CreateSignalViewModel, id);

            return(this.RedirectToAction(
                       "All",
                       "Signals",
                       new { returnedId = hotelId }));
        }
示例#2
0
        public async Task CreateAsync(HotelInformationViewModel model, string id)
        {
            var hotelId = id.Split()[0];

            var room = new Room()
            {
                RoomNumber = model.RoomRegisterViewModel.RoomNumber,
                Floor      = model.RoomRegisterViewModel.Floor,
                RoomType   = model.RoomRegisterViewModel.Type,
                HotelId    = hotelId,
            };

            await this.roomRepo.AddAsync(room);

            await this.roomRepo.SaveChangesAsync();
        }
示例#3
0
        public async Task CreateAsync(HotelInformationViewModel model, string id)
        {
            var date = DateTime.Parse($"{model.CreateEventViewModel.Date}T{model.CreateEventViewModel.Time}");

            var @event = new Event()
            {
                Title       = model.CreateEventViewModel.Title,
                Date        = date,
                Description = model.CreateEventViewModel.Description,
                HotelId     = id.Split()[0],
            };

            await this.eventRepo.AddAsync(@event);

            await this.eventRepo.SaveChangesAsync();
        }
        public async Task <IActionResult> Update(HotelInformationViewModel model, string id)
        {
            var hotelId = await this.userService.UpdateAsync(model.EditUserViewModel, id);

            return(this.RedirectToAction("All", "Employees", new { returnedId = hotelId }));
        }
        public async Task <IActionResult> ChangePhoto(HotelInformationViewModel model)
        {
            await this.userService.ChangePhotoAsync(model.UserProfileViewModel);

            return(this.Redirect("/Home/Index"));
        }
示例#6
0
        public async Task <IActionResult> Create(HotelInformationViewModel model, string id)
        {
            await this.eventService.CreateAsync(model, id);

            return(this.RedirectToAction("All", "Events", new { returnedId = id }));
        }
示例#7
0
        public async Task <HotelInformationViewModel> LoadCurrentHotelAsync(string id)
        {
            var             hotelInfo    = id?.Split();
            var             hotelId      = hotelInfo != null ? hotelInfo[0] : null;
            string          role         = string.Empty;
            string          employeeRole = string.Empty;
            Reservation     reservation  = null;
            ApplicationUser user         = null;
            ApplicationUser currentUser  = null;

            if (hotelInfo?.Length >= 2)
            {
                role = hotelInfo[1];
            }

            if (hotelInfo?.Length >= 3)
            {
                var currentId = hotelInfo[2];
                reservation = await this.reservationRepo.GetAsync(currentId);

                user = await this.userRepo.GetAsync(currentId);
            }

            if (hotelInfo?.Length == 4)
            {
                employeeRole = hotelInfo[3];
            }

            if (role == "Guest")
            {
                user        = (await this.userRepo.GetAllAsync()).FirstOrDefault(u => u.Id == this.httpContextAccessor.HttpContext.User.FindFirst("Id").Value);
                reservation = (await this.reservationRepo.GetAllAsync()).FirstOrDefault(r =>
                                                                                        r.Guest.Id == user.Id &&
                                                                                        r.EndDate.AddDays(1) > DateTime.Now);
            }

            var userId = this.httpContextAccessor.HttpContext.User.FindFirst("Id").Value;

            currentUser = await this.userRepo.GetAsync(userId);

            var hotel = await this.hotelRepo.GetAsync(hotelId);

            var floors = (await this.roomRepo.GetAllAsync()).Where(r => r.HotelId == hotelId).Select(r => r.Floor).ToHashSet();

            var cleanings = (await this.cleaningRepo.GetAllAsync()).Where(c => c.Room.HotelId == hotelId).ToList();

            var cleaners = (await this.userHotelRoleRepo.GetAllAsync()).Where(uh => uh.HotelRole.HotelId == hotelId && uh.HotelRole.Role.Name == "Cleaner").ToList();

            var receptionists = (await this.userHotelRoleRepo.GetAllAsync()).Where(uh => uh.HotelRole.HotelId == hotelId && uh.HotelRole.Role.Name == "Receptionist").ToList();

            var isManager = (await this.userHotelRoleRepo.GetAllAsync())
                            .Where(uhr => uhr.User.Id == userId && uhr.HotelRole.HotelId == hotelId)
                            .Any(uhr => uhr.User.UserHotelRoles.Any(u => u.HotelRole.Role.Name == "Manager"));

            var model = new HotelInformationViewModel()
            {
                Hotel         = hotel,
                Cleaners      = cleaners,
                Receptionists = receptionists,
                IsManager     = isManager,
                Role          = role,
                EmployeeRole  = employeeRole,
                Reservation   = reservation,
                User          = user,
                Cleanings     = cleanings,
                Floors        = floors,
                UserId        = userId,
                CurrentUser   = currentUser,
            };

            return(model);
        }
        public async Task <IActionResult> Clean(HotelInformationViewModel model, string id)
        {
            var hotelId = await this.cleaningService.CleanAsync(model.CleanRoomViewModel, id);

            return(this.RedirectToAction("Upcoming", "Cleanings", new { returnedId = hotelId }));
        }
示例#9
0
        public async Task <IActionResult> Create(HotelInformationViewModel model, string id)
        {
            await this.roomService.CreateAsync(model, id);

            return(this.RedirectToAction("Dashboard", "Home", new { returnedId = id }));
        }