public void Delete(EoDSearch request) { var matches = Get(request) as List <EoD>; if (true != matches?.Any()) { throw new HttpError(HttpStatusCode.NotFound, "No matches for request"); } matches.ForEach(match => { Delete(match); }); }
public object Get(EoDSearch request) => GetSearchResultWithCache <EoD, DocEntityEoD, EoDSearch>(DocConstantModelName.EOD, request, _ExecSearch);
private IQueryable <DocEntityEoD> _ExecSearch(EoDSearch request, DocQuery query) { request = InitSearch <EoD, EoDSearch>(request); IQueryable <DocEntityEoD> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityEoD>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new EoDFullTextSearch(request); entities = GetFullTextSearch <DocEntityEoD, EoDFullTextSearch>(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.EOD, 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 (!DocTools.IsNullOrEmpty(request.Assignee) && !DocTools.IsNullOrEmpty(request.Assignee.Id)) { entities = entities.Where(en => en.Assignee.Id == request.Assignee.Id); } if (true == request.AssigneeIds?.Any()) { entities = entities.Where(en => en.Assignee.Id.In(request.AssigneeIds)); } if (!DocTools.IsNullOrEmpty(request.Description)) { entities = entities.Where(en => en.Description.Contains(request.Description)); } if (!DocTools.IsNullOrEmpty(request.Descriptions)) { entities = entities.Where(en => en.Description.In(request.Descriptions)); } if (!DocTools.IsNullOrEmpty(request.DueDate)) { entities = entities.Where(en => null != en.DueDate && request.DueDate.Value.Date == en.DueDate.Value.Date); } if (!DocTools.IsNullOrEmpty(request.DueDateBefore)) { entities = entities.Where(en => en.DueDate <= request.DueDateBefore); } if (!DocTools.IsNullOrEmpty(request.DueDateAfter)) { entities = entities.Where(en => en.DueDate >= request.DueDateAfter); } if (!DocTools.IsNullOrEmpty(request.Reporter) && !DocTools.IsNullOrEmpty(request.Reporter.Id)) { entities = entities.Where(en => en.Reporter.Id == request.Reporter.Id); } if (true == request.ReporterIds?.Any()) { entities = entities.Where(en => en.Reporter.Id.In(request.ReporterIds)); } if (request.Type.HasValue) { entities = entities.Where(en => request.Type.Value == en.Type); } if (!DocTools.IsNullOrEmpty(request.Types)) { entities = entities.Where(en => en.Type.In(request.Types)); } 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)); } if (!DocTools.IsNullOrEmpty(request.Assignee) && !DocTools.IsNullOrEmpty(request.Assignee.Id)) { entities = entities.Where(en => en.Assignee.Id == request.Assignee.Id); } if (true == request.AssigneeIds?.Any()) { entities = entities.Where(en => en.Assignee.Id.In(request.AssigneeIds)); } if (!DocTools.IsNullOrEmpty(request.Description)) { entities = entities.Where(en => en.Description.Contains(request.Description)); } if (!DocTools.IsNullOrEmpty(request.Descriptions)) { entities = entities.Where(en => en.Description.In(request.Descriptions)); } if (!DocTools.IsNullOrEmpty(request.Document) && !DocTools.IsNullOrEmpty(request.Document.Id)) { entities = entities.Where(en => en.Document.Id == request.Document.Id); } if (true == request.DocumentIds?.Any()) { entities = entities.Where(en => en.Document.Id.In(request.DocumentIds)); } if (!DocTools.IsNullOrEmpty(request.DueDate)) { entities = entities.Where(en => null != en.DueDate && request.DueDate.Value.Date == en.DueDate.Value.Date); } if (!DocTools.IsNullOrEmpty(request.DueDateBefore)) { entities = entities.Where(en => en.DueDate <= request.DueDateBefore); } if (!DocTools.IsNullOrEmpty(request.DueDateAfter)) { entities = entities.Where(en => en.DueDate >= request.DueDateAfter); } if (!DocTools.IsNullOrEmpty(request.Reporter) && !DocTools.IsNullOrEmpty(request.Reporter.Id)) { entities = entities.Where(en => en.Reporter.Id == request.Reporter.Id); } if (true == request.ReporterIds?.Any()) { entities = entities.Where(en => en.Reporter.Id.In(request.ReporterIds)); } if (request.Status.HasValue) { entities = entities.Where(en => request.Status.Value == en.Status); } if (!DocTools.IsNullOrEmpty(request.Statuss)) { entities = entities.Where(en => en.Status.In(request.Statuss)); } if (request.Type.HasValue) { entities = entities.Where(en => request.Type.Value == en.Type); } if (!DocTools.IsNullOrEmpty(request.Types)) { entities = entities.Where(en => en.Type.In(request.Types)); } 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 <DocEntityEoD, EoDSearch>(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(EoDSearch request) => Get(request);