public void Delete(LookupTableBindingSearch request) { var matches = Get(request) as List <LookupTableBinding>; if (true != matches?.Any()) { throw new HttpError(HttpStatusCode.NotFound, "No matches for request"); } matches.ForEach(match => { Delete(match); }); }
public object Get(LookupTableBindingSearch request) => GetSearchResultWithCache <LookupTableBinding, DocEntityLookupTableBinding, LookupTableBindingSearch>(DocConstantModelName.LOOKUPTABLEBINDING, request, _ExecSearch);
private IQueryable <DocEntityLookupTableBinding> _ExecSearch(LookupTableBindingSearch request, DocQuery query) { request = InitSearch <LookupTableBinding, LookupTableBindingSearch>(request); IQueryable <DocEntityLookupTableBinding> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityLookupTableBinding>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new LookupTableBindingFullTextSearch(request); entities = GetFullTextSearch <DocEntityLookupTableBinding, LookupTableBindingFullTextSearch>(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.LOOKUPTABLEBINDING, 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.BoundName)) { entities = entities.Where(en => en.BoundName.Contains(request.BoundName)); } if (!DocTools.IsNullOrEmpty(request.BoundNames)) { entities = entities.Where(en => en.BoundName.In(request.BoundNames)); } if (!DocTools.IsNullOrEmpty(request.LookupTable) && !DocTools.IsNullOrEmpty(request.LookupTable.Id)) { entities = entities.Where(en => en.LookupTable.Id == request.LookupTable.Id); } if (true == request.LookupTableIds?.Any()) { entities = entities.Where(en => en.LookupTable.Id.In(request.LookupTableIds)); } else if (!DocTools.IsNullOrEmpty(request.LookupTable) && !DocTools.IsNullOrEmpty(request.LookupTable.Name)) { entities = entities.Where(en => en.LookupTable.Name == request.LookupTable.Name); } if (true == request.LookupTableNames?.Any()) { entities = entities.Where(en => en.LookupTable.Name.In(request.LookupTableNames)); } if (!DocTools.IsNullOrEmpty(request.Scope) && !DocTools.IsNullOrEmpty(request.Scope.Id)) { entities = entities.Where(en => en.Scope.Id == request.Scope.Id); } if (true == request.ScopeIds?.Any()) { entities = entities.Where(en => en.Scope.Id.In(request.ScopeIds)); } if (true == request.SynonymsIds?.Any()) { entities = entities.Where(en => en.Synonyms.Any(r => r.Id.In(request.SynonymsIds))); } if (true == request.WorkflowsIds?.Any()) { entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds))); } entities = ApplyFilters <DocEntityLookupTableBinding, LookupTableBindingSearch>(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(LookupTableBindingSearch request) => Get(request);