Example #1
0
        public ActionResult ApproveRequest(int id)
        {
            try
            {
                var user           = _userManager.GetUserAsync(User).Result;
                var bookingrequest = _bookingRequestRepo.FindById(id);
                var employeeid     = bookingrequest.EmployeeBookingRoomId;
                var roomtypeId     = bookingrequest.RoomTypeId;
                var allocation     = _bookingRepo.GetBookingsByEmployeeAndType(employeeid, roomtypeId);
                int daysRequested  = (int)(bookingrequest.CheckOutDate - bookingrequest.CheckinDate).TotalDays;
                allocation.NumberOfDays = allocation.NumberOfDays - daysRequested;

                bookingrequest.Approved            = true;
                bookingrequest.BookingApprovedById = user.Id;
                bookingrequest.DateActioned        = DateTime.Now;

                _bookingRequestRepo.Update(bookingrequest);
                _bookingRepo.Update(allocation);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task CancelBooking(Guid id, Guid clientId)
        {
            var booking = await bookings.FindById(id, clientId);

            booking.Cancelled = true;
            booking.Confirmed = false;
            var result = await bookings.Update(booking, clientId);
        }
Example #3
0
        public async Task Update(Guid id, UpdateBookingRequestDto request)
        {
            var bookingRequest = await GetById(id);

            bookingRequest.ItemId    = request.ItemId;
            bookingRequest.StartDate = request.StartDate;
            bookingRequest.EndDate   = request.EndDate;
            bookingRequest.Comment   = request.Comment;

            _repository.Update(bookingRequest);
            await _context.SaveChangesAsync();
        }