示例#1
0
        public async Task <Question> Execute(PangulDbContext db, GetQuestion query)
        {
            query.Validate();

            var qStatement = db.Question
                             .Where(q => q.QuestionId == query.Derived.QuestionId);

            if (!query.IgnoreRowVersion)
            {
                qStatement = qStatement.Where(q => q.RowVersion == query.Derived.RowVersion);
            }

            if (query.LightWeightOnly)
            {
                return(await qStatement.FirstOrDefaultAsync());
            }

            var question = await qStatement
                           .Include(i => i.Tags)
                           .Include(i => i.Meta)
                           .Include(i => i.Topic)
                           .FirstOrDefaultAsync();

            if (question != null)
            {
                question.CanEdit = await _internalUserPermissionService.HasWriteAccessFor(question, query.UserContext);
            }

            return(question);
        }
示例#2
0
 private async Task DerviePermissionsForInstance(GetAnswer query, Answer answer)
 {
     if (answer == null)
     {
         return;
     }
     answer.CanEdit = await _internalUserPermissionService.HasWriteAccessFor(answer, query.UserContext);
 }