Пример #1
0
        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()));
            }
        }