Ejemplo n.º 1
0
        public async Task <IActionResult> Review(int requisitionId)
        {
            var requisition = await _dbContext.Requisitions.GetRequisitionById(requisitionId);

            if (ModelState.IsValid)
            {
                if ((await _authorizationService.AuthorizeAsync(User, requisition, Policies.Accept)).Succeeded)
                {
                    try
                    {
                        await _requisitionService.Review(requisition, User.GetUserId(), User.TryGetImpersonatorId());
                    }
                    catch (InvalidOperationException ex)
                    {
                        _logger.LogError("Failed to review requisition, requisitionId: {requisition.RequisitionId}, message {Message}", requisition.RequisitionId, ex.Message);
                        return(RedirectToAction("View", "Order", new { id = requisition.Request.OrderId, errormessage = ex.Message }));
                    }
                    return(RedirectToAction("View", "Order", new { id = requisition.Request.OrderId, tab = "requisition" }));
                }
                return(Forbid());
            }
            return(RedirectToAction("View", "Order", new { id = requisition.Request.OrderId, tab = "requisition" }));
        }