예제 #1
0
        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()));
            }
        }
예제 #2
0
        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()));
            }
        }