Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteReservation(int id)
        {
            var playgroundId        = _userManager.GetUserId(User);
            var acceptedReservation = _reservationRepository.GetPlaygroundReservationById(id);

            if (acceptedReservation.UserId != null)
            {
                await NotifyUser(playgroundId, acceptedReservation, $"Sorry, your reservation request has been rejected  for {acceptedReservation.Date} day from {acceptedReservation.StartTime} to {acceptedReservation.EndTime}");
            }
            _reservationRepository.Delete(id);
            var dataModel = new DataViewModel();

            dataModel.Reservations = _reservationRepository.GetReservationsByDay(playgroundId, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);
            dataModel.Requests     = _reservationRepository.GetRequests(playgroundId);
            dataModel.IsAdmin      = true;
            if (acceptedReservation.Status == "Accepted")
            {
                return(PartialView("_Reservation", dataModel));
            }
            else
            {
                return(PartialView("_Request", dataModel));
            }
        }
Ejemplo n.º 2
0
        public IViewComponentResult Invoke(DataViewModel dataModel)
        {
            string userId = null;

            if (dataModel.Entity != null)
            {
                userId = dataModel.Entity.Id;
            }
            else if (dataModel.Entity == null)
            {
                userId           = dataModel.CurrentUser.Id;
                dataModel.Entity = dataModel.CurrentUser;
            }
            var requests          = _repository.GetRequests(userId);
            var todayReservations = _repository.GetReservationsByDay(userId, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year).OrderBy(c => c.StartTime);
            var allReservations   = _repository.GetAll(userId);

            dataModel.Reservations    = todayReservations;
            dataModel.Requests        = requests;
            dataModel.AllReservations = allReservations;
            return(View("/Components/Reservation/Reservation.cshtml", dataModel));
        }