public async Task <ActionResult> Cancel() { string user_id = Request.Headers.FirstOrDefault(header => header.Key == "user_id").Value; string res_id = Request.Headers.FirstOrDefault(header => header.Key == "res_id").Value; var resul = await _repository.Cancel(user_id, res_id); if (resul == 200) { return(Ok()); } else if (resul == 404) { return(NotFound("Reservation does not exist")); } else if (resul == 401) { return(Unauthorized("You have no permission to perform this action")); } else if (resul == 4011) { return(Unauthorized("Your user has been deactivated by admin")); } else { return(BadRequest("Invalid Reservation")); } }
public async Task <int> Cancel(int reservationId) { var reservation = await _reservationRepository.GetById(reservationId); if (reservation == null) { return(0); } await _reservationRepository.Cancel(reservation); return(reservationId); }
public Reservation Cancel(Guid id) { var reservation = Get(id); if (reservation == null || reservation.Status != ReservationStatus.Pending) { return(null); } var reservationEntity = _reservationRepository.Cancel(id); var updatedReservation = _mapper.Map <Reservation>(reservationEntity); _emailService.SendReservationCanceledNotification(updatedReservation); return(updatedReservation); }