public async Task <IActionResult> CheckOutGamingPatron([FromRoute] string serviceId, [FromRoute] string patronId) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Checkout the gaming patron. await _managerService.CheckOutGamingPatron(managerId, serviceId, patronId); // Return an empty OK status. return(Ok()); } catch (PatronNotFoundException e) { // Error: Patron specified not found. _logger.LogInformation(e, "Could not find specified gaming patron for update. [mId: {managerId}, sId: {serviceId}, pId: {patronId}]", managerId, serviceId, patronId); return(BadRequest(APIError.PatronNotFound())); } catch (NoAccessException e) { // Error: Manager does not have sufficient permissions to checkout the gaming patron. _logger.LogInformation(e, "Manager was denied access to checkout gaming patron. [mId: {managerId}, sId: {serviceId}]", managerId, serviceId); return(BadRequest(APIError.NoAccess())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to checkout gaming patron"); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> CloseDiningTable([FromRoute] string serviceId, [FromRoute] string tableId) { // Pull manager ID from the HTTP context string managerId = HttpContext.User.Identity.Name; try { // Close the dining table. await _managerService.CloseDiningTable(managerId, serviceId, tableId); // Return an empty OK status. return(Ok()); } catch (TableNotFoundException e) { // Error: Table specified could not be found. _logger.LogInformation(e, "Could not find specified dining sitting. [service: {serviceId}, sitting: {tableId}]", serviceId, tableId); return(BadRequest(APIError.TableNotFound())); } catch (NoAccessException e) { // Error: Manager does not have sufficient permission to close the requested dining table. _logger.LogInformation(e, "Manager was denied access to close dining table. [mId: {managerId}, sId: {serviceId}]", managerId, serviceId); return(BadRequest(APIError.NoAccess())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to close dining table"); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> UpdateDiningPatron( [FromRoute] string serviceId, [FromRoute] string tableId, [FromRoute] string checkInId, [FromRoute] string patronId, [FromBody] DiningPatronUpdateRequest update ) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Update the dining patron with new information. await _managerService.UpdateDiningPatron(managerId, serviceId, tableId, checkInId, patronId, update); // Return an empty OK status. return(Ok()); } catch (TableNotFoundException e) { // Error: Table specified could not be found. _logger.LogInformation(e, "Could not find specified dining sitting to update patron. [service: {serviceId}, sitting: {tableId}]", serviceId, tableId); return(BadRequest(APIError.TableNotFound())); } catch (CheckInNotFoundExcption e) { // Error: Check-in specified could not be found. _logger.LogInformation(e, "Could not find specified dining check-in to update patron. [service: {serviceId}, sitting: {tableId}, checkIn: {checkInId}]", serviceId, tableId, checkInId); return(BadRequest(APIError.CheckInNotFound())); } catch (PatronNotFoundException e) { // Error: Patron specified for update does not exist. _logger.LogInformation(e, "Could not find specified dining patron for update. [mId: {managerId}, sId: {serviceId}, pId: {patronId}]", managerId, serviceId, patronId); return(BadRequest(APIError.PatronNotFound())); } catch (NoAccessException e) { // Error: Manager does not have sufficient access to update the dining patron. _logger.LogInformation(e, "Manager was denied access to update dining patron. [mId: {managerId}, sId: {serviceId}]", managerId, serviceId); return(BadRequest(APIError.NoAccess())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to update dining patron"); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> MoveDiningGroup( [FromRoute] string serviceId, [FromRoute] string tableId, [FromRoute] string checkInId, [FromRoute] string tableNumber ) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Move the dining group and return the table ID. return(Ok(new { TableId = await _managerService.MoveDiningGroup(managerId, serviceId, tableId, checkInId, tableNumber) })); } catch (TableNotFoundException e) { // Error: Table specified could not be found. _logger.LogInformation(e, "Could not find specified dining sitting. [service: {serviceId}, sitting: {tableId}]", serviceId, tableId); return(BadRequest(APIError.TableNotFound())); } catch (CheckInNotFoundExcption e) { // Error: Check-in specified could not be found. _logger.LogInformation(e, "Could not find specified dining check-in. [service: {serviceId}, sitting: {tableId}, checkIn: {checkInId}]", serviceId, tableId, checkInId); return(BadRequest(APIError.CheckInNotFound())); } catch (NoAccessException e) { // Error: Manager does not have sufficient access to move the dining group. _logger.LogInformation(e, "Manager was denied access to move dining group. [mId: {managerId}, sId: {serviceId}]", managerId, serviceId); return(BadRequest(APIError.NoAccess())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to move dining check-in"); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> StopGamingService([FromRoute] string venueId, [FromRoute] string areaId) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Stop the gaming service in the venue + area. await _managerService.StopGamingService(managerId, venueId, areaId); // Return an empty OK status. return(Ok()); } catch (NoAccessException e) { // Error: Manager does not have access to the target venue/area. _logger.LogInformation(e, "Manager was denied access to stop gaming service. [mId: {managerId}, vId: {venueId}, aId: {areaId}]", managerId, venueId, areaId); return(BadRequest(APIError.NoAccess())); } catch (AreaNotFoundException e) { // Error: Area does not exist or cannot be found. _logger.LogError(e, "Cannot stop gaming service in unknown area. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaNotFound())); } catch (AreaHasNoActiveServiceException e) { // Error: Area does not have an active service. _logger.LogInformation(e, "Gaming service cannot be stoppd as there is no active service in the specified venue/area. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaHasNoActiveService())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to stop gaming service [vId: {venueId}]", venueId); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> StopDiningService([FromRoute] string venueId, [FromRoute] string areaId) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Stop the dining service. await _managerService.StopDiningService(managerId, venueId, areaId); // Return an empty OK status. return(Ok()); } catch (NoAccessException e) { // Error: Manager does not have access to the area/venue which they tried to modify. _logger.LogInformation(e, "Manager was denied access to stop dining service. [mId: {managerId}, vId: {venueId}, aId: {areaId}]", managerId, venueId, areaId); return(BadRequest(APIError.NoAccess())); } catch (AreaNotFoundException e) { // Error: Area specified doesn't exist. _logger.LogError(e, "Cannot stop dining service in unknown area. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaNotFound())); } catch (AreaHasNoActiveServiceException e) { // Error: Target area does not have an active service, and therefore cannot be stopped. _logger.LogError(e, "Cannot stop service in an area that has no active service. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaHasNoActiveService())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to stop dining service [vId: {venueId}]", venueId); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> StartGamingService([FromRoute] string venueId, [FromRoute] string areaId) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Start a new gaming service and return it. return(Ok(new { Service = await _managerService.StartGamingService(managerId, venueId, areaId) })); } catch (NoAccessException e) { // Error: Manager does not have access to the specified venue and area. _logger.LogInformation(e, "Manager was denied access to start gaming service. [mId: {managerId}, vId: {venueId}, aId: {areaId}]", managerId, venueId, areaId); return(BadRequest(APIError.NoAccess())); } catch (AreaNotFoundException e) { // Error: Target area does not exist, or could not be found. _logger.LogError(e, "Cannot start gaming service in an unknown area. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaNotFound())); } catch (AreaHasActiveServiceException) { // Error: Target area already has an active service, and therefore cannot have a new service started. return(BadRequest(APIError.AreaHasActiveService())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to start gaming service [vId: {venueId}]", venueId); return(BadRequest(APIError.UnknownError())); } }
public async Task <IActionResult> StartDiningService([FromRoute] string venueId, [FromRoute] string areaId) { // Pull manager ID from the HTTP context. string managerId = HttpContext.User.Identity.Name; try { // Start a new service and return it. return(Ok(new { Service = await _managerService.StartDiningService(managerId, venueId, areaId) })); } catch (NoAccessException e) { // Error: Manager does not have access to create/start a dining service in the given area. _logger.LogInformation(e, "Manager was denied acess to start dining service. [mId: {managerId}, vId: {venueId}, aId: {areaId}]", managerId, venueId, areaId); return(BadRequest(APIError.NoAccess())); } catch (AreaNotFoundException e) { // Error: The requested area does not exist. _logger.LogError(e, "Cannot start dining service in unknown area. [vId: {venueId}, aId: {areaId}]", venueId, areaId); return(BadRequest(APIError.AreaNotFound())); } catch (AreaHasActiveServiceException) { // Error: The area specified already has an active service which needs to be stopped before it can be started again. return(BadRequest(APIError.AreaHasActiveService())); } catch (Exception e) { // Error: Unknown error. _logger.LogError(e, "Failed to start dining service [vId: {venueId}]", venueId); return(BadRequest(APIError.UnknownError())); } }