Exemplo n.º 1
0
        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()));
            }
        }
Exemplo n.º 2
0
        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()));
            }
        }