public void Delete(WorkflowCommentSearch request) { var matches = Get(request) as List <WorkflowComment>; if (true != matches?.Any()) { throw new HttpError(HttpStatusCode.NotFound, "No matches for request"); } matches.ForEach(match => { Delete(match); }); }
private IQueryable <DocEntityWorkflowComment> _ExecSearch(WorkflowCommentSearch request, DocQuery query) { request = InitSearch <WorkflowComment, WorkflowCommentSearch>(request); IQueryable <DocEntityWorkflowComment> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityWorkflowComment>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new WorkflowCommentFullTextSearch(request); entities = GetFullTextSearch <DocEntityWorkflowComment, WorkflowCommentFullTextSearch>(fts, entities); } if (null != request.Ids && request.Ids.Any()) { entities = entities.Where(en => en.Id.In(request.Ids)); } if (!DocTools.IsNullOrEmpty(request.Updated)) { entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date); } if (!DocTools.IsNullOrEmpty(request.UpdatedBefore)) { entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore); } if (!DocTools.IsNullOrEmpty(request.UpdatedAfter)) { entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter); } if (!DocTools.IsNullOrEmpty(request.Created)) { entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date); } if (!DocTools.IsNullOrEmpty(request.CreatedBefore)) { entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore); } if (!DocTools.IsNullOrEmpty(request.CreatedAfter)) { entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter); } if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.WORKFLOWCOMMENT, nameof(Reference.Archived), DocConstantPermission.VIEW)) { entities = entities.Where(en => en.Archived.In(request.Archived)); } else { entities = entities.Where(en => !en.Archived); } if (true == request.Locked?.Any()) { entities = entities.Where(en => en.Locked.In(request.Locked)); } if (true == request.ChildrenIds?.Any()) { entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds))); } if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Id)) { entities = entities.Where(en => en.Parent.Id == request.Parent.Id); } if (true == request.ParentIds?.Any()) { entities = entities.Where(en => en.Parent.Id.In(request.ParentIds)); } if (!DocTools.IsNullOrEmpty(request.Text)) { entities = entities.Where(en => en.Text.Contains(request.Text)); } if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id)) { entities = entities.Where(en => en.User.Id == request.User.Id); } if (true == request.UserIds?.Any()) { entities = entities.Where(en => en.User.Id.In(request.UserIds)); } if (!DocTools.IsNullOrEmpty(request.Workflow) && !DocTools.IsNullOrEmpty(request.Workflow.Id)) { entities = entities.Where(en => en.Workflow.Id == request.Workflow.Id); } if (true == request.WorkflowIds?.Any()) { entities = entities.Where(en => en.Workflow.Id.In(request.WorkflowIds)); } entities = ApplyFilters <DocEntityWorkflowComment, WorkflowCommentSearch>(request, entities); if (request.Skip > 0) { entities = entities.Skip(request.Skip.Value); } if (request.Take > 0) { entities = entities.Take(request.Take.Value); } if (true == request?.OrderBy?.Any()) { entities = entities.OrderBy(request.OrderBy); } if (true == request?.OrderByDesc?.Any()) { entities = entities.OrderByDescending(request.OrderByDesc); } }); return(entities); }
public object Post(WorkflowCommentSearch request) => Get(request);
public object Get(WorkflowCommentSearch request) => GetSearchResultWithCache <WorkflowComment, DocEntityWorkflowComment, WorkflowCommentSearch>(DocConstantModelName.WORKFLOWCOMMENT, request, _ExecSearch);
public WorkflowCommentFullTextSearch(WorkflowCommentSearch request) => _request = request;