Ejemplo n.º 1
0
        public async Task <IActionResult> IndexAsync([FromQuery] AnimalFilter animalFilters)
        {
            var vm = new StayViewModel();

            vm.Stays = await _stayRepository.HandleFilter(animalFilters);

            return(View(vm));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            var currentUser      = this.userManager.GetUserAsync(this.User).Result;
            var rewardsViewModel = new RewardsInputModel();
            var stays            = this.staysService.GetAllStaysForUser(currentUser.Id);

            // Gets all stays for the user including the data for the hotxel and sorted by date of booking

            int totalPoints = this.staysService.GetTotalPoints(currentUser.Id);

            // Gets total points of all stays, which are not canceled. User will get points only if departure date is
            // less or equal to today's date
            int pointsRefunded = this.staysService.GetRefundedPoints(currentUser.Id);

            // Gets total points for canceled reservation and refund it to the user so he can use them again
            var userTier = string.Empty;

            if (totalPoints <= StaticData.RewardsTier1Requirement)
            {
                userTier = StaticData.Tiers.Silver.ToString();
            }
            else if (totalPoints >= StaticData.RewardsTier2Requirement)
            {
                userTier = StaticData.Tiers.Gold.ToString();
            }
            else if (totalPoints >= StaticData.RewardsTier3Requirement)
            {
                userTier = StaticData.Tiers.Platinum.ToString();
            }

            // Get the user tier acording to total points earned
            totalPoints = totalPoints - currentUser.UsedPoints + pointsRefunded;
            // Gets the remaining points for the user
            rewardsViewModel.UserDataViewModel.TotalPoints = totalPoints;
            rewardsViewModel.UserDataViewModel.RewardsTier = userTier;

            foreach (var stay in stays)
            {
                var stayViewModel = new StayViewModel()
                {
                    ConfirmationNumber = stay.ConfirmationNumber,
                    Hotel         = stay.Hotel.Name,
                    RoomType      = stay.RoomType,
                    ArrivalDate   = stay.ArrivalDate,
                    DepartureDate = stay.DepartureDate,
                    PointsSpend   = stay.PointsSpend,
                    PointsEarned  = stay.PointsEarned,
                    Price         = stay.Price,
                    TotalPrice    = stay.TotalPrice,
                    StayId        = stay.Id,
                    IsCanceled    = stay.IsCanceled,
                    BookedOn      = stay.BookedOn,
                };
                rewardsViewModel.StayViewModels.Add(stayViewModel);
            }

            return(this.View(rewardsViewModel));
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            var vm = new StayViewModel()
            {
                Stays   = _stayService.GetAll().ToList(),
                Animals = _animalService.GetAll().ToList(),
                Lodges  = _lodgingService.GetAll().ToList()
            };

            return(View(vm));
        }
Ejemplo n.º 4
0
        public IActionResult Edit(int ID)
        {
            var stay = _stayService.FindByID(ID);
            var vm   = new StayViewModel()
            {
                Lodges       = _lodgingService.ReturnAvailableLocations(stay.AnimalID), // Only get lodges with proper type & those that have space left.
                Stay         = stay,
                CurrentLodge = _lodgingService.FindByID(stay.LodgingLocationID),
                Animal       = _animalService.FindByID(stay.AnimalID)
            };

            return(View(vm));
        }
Ejemplo n.º 5
0
        public IActionResult Edit(StayViewModel stayViewModel)
        {
            try
            {
                _stayService.PlaceAnimal(stayViewModel.Stay, stayViewModel.Lodge);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                ViewBag.Message = "Error: " + e.Message;
                return(Edit(stayViewModel.Stay.ID));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Filter(StayViewModel stay)
        {
            var vm = new StayViewModel();

            AnimalFilter filter = new AnimalFilter
            {
                Gender        = stay.Animal.Gender,
                AnimalType    = stay.Animal.AnimalType,
                ChildFriendly = stay.Animal.ChildFriendly,
                CanBeAdopted  = true
            };

            vm.Stays = await _stayRepository.HandleFilter(filter);

            return(View("Views/Stay/Index.cshtml", vm));
        }