Ejemplo n.º 1
0
        private UserRequest GetUserRequest(UserRequest request)
        {
            var         id    = request?.Id;
            UserRequest ret   = null;
            var         query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <UserRequest>(currentUser, "UserRequest", request.Select);

            DocEntityUserRequest entity = null;

            if (id.HasValue)
            {
                entity = DocEntityUserRequest.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No UserRequest found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }