public override async Task <PageList <GasLog> > GetEntitiesAsync(ResourceCollectionParameters resourceCollectionParameters = null) { try { var notes = await GetNotesAsync(new GasLog(), null, resourceCollectionParameters); if (notes == null) { return(null); } var logList = notes.Select(note => NoteSerializer.GetEntity(note)); var result = new PageList <GasLog>(logList, notes.TotalCount, notes.CurrentPage, notes.PageSize); return(result); } catch (Exception e) { if (NoteSerializer.ProcessResult.Success) { ProcessResult.WrapException(e); } else { ProcessResult.PropagandaResult(NoteSerializer.ProcessResult); } return(null); } }
public override PageList <AutomobileInfo> GetEntities(ResourceCollectionParameters resourceCollectionParameters = null) { try { var notes = GetNotes(new AutomobileInfo(), null, resourceCollectionParameters); if (notes == null) { return(null); } var carList = notes.Select(note => NoteSerializer.GetEntity(note)); var result = new PageList <AutomobileInfo>(carList, notes.TotalCount, notes.CurrentPage, notes.PageSize); return(result); } catch (Exception e) { if (NoteSerializer.ProcessResult.Success) { ProcessResult.WrapException(e); } else { ProcessResult.PropagandaResult(NoteSerializer.ProcessResult); } return(null); } }
public PageList <GasLog> GetGasLogs(int automobileId, ResourceCollectionParameters resourceCollectionParameters = null) { var subject = GasLog.GetNoteSubject(automobileId); var notes = GetNotes(new GasLog(), n => n.Subject == subject, resourceCollectionParameters); var logList = notes.Select(note => NoteSerializer.GetEntity(note)); var result = new PageList <GasLog>(logList, notes.TotalCount, notes.CurrentPage, notes.PageSize); return(result); }
public async Task <IActionResult> Get([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var noteList = await _noteManager.GetNotesAsync(null, false, resourceCollectionParameters); if (!noteList.Any()) { return(NotFound()); } return(Ok(noteList)); }
public async Task <IActionResult> Get([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var authors = await _authorManager.GetEntitiesAsync(null, resourceCollectionParameters); if (!authors.Any()) { return(NotFound()); } return(Ok(authors)); }
public async Task <IActionResult> Get([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var renderLst = await _renderManager.GetEntitiesAsync(null, resourceCollectionParameters); if (!renderLst.Any()) { return(NotFound()); } return(Ok(renderLst)); }
public async Task <IActionResult> GetMobiles([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var autos = await _automobileManager.GetEntitiesAsync(resourceCollectionParameters); if (!autos.Any()) { return(NotFound()); } return(Ok(autos)); }
public async Task <ActionResult> Get([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var discounts = await _discountManager.GetEntitiesAsync(resourceCollectionParameters); if (!discounts.Any()) { return(NotFound()); } return(Ok(discounts)); }
public async Task <IActionResult> Get([FromQuery] ResourceCollectionParameters resourceCollectionParameters) { var noteCatalogs = await _catalogManager.GetEntitiesAsync(null, resourceCollectionParameters); if (!noteCatalogs.Any()) { return(NotFound()); } return(Ok(noteCatalogs)); }
public override PageList <GasLog> GetEntities(ResourceCollectionParameters resourceCollectionParameters = null) { var notes = GetNotes(new GasLog(), null, resourceCollectionParameters); if (notes == null) { return(null); } var logList = notes.Select(note => NoteSerializer.GetEntity(note)); var result = new PageList <GasLog>(logList, notes.TotalCount, notes.CurrentPage, notes.PageSize); return(result); }
public static (int pageIndex, int pageSize) GetPaginationTuple(this ResourceCollectionParameters parameter) { switch (parameter) { case null: { var defaultParam = new ResourceCollectionParameters(); return(defaultParam.PageNumber, defaultParam.PageSize); } default: return(parameter.PageNumber, parameter.PageSize); } }
public IEnumerable <Appointment> GetAppointments(Expression <Func <Appointment, bool> > query, ResourceCollectionParameters resourceCollectionParameters = null) { return(_appointRepo.GetEntities().ToList()); }
public async Task <PageList <HmmNote> > GetEntitiesAsync(Expression <Func <HmmNote, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var(pageIdx, pageSize) = resourceCollectionParameters.GetPaginationTuple(); var notes = query == null ? DataContext.Notes.Include(n => n.Author).Include(n => n.Catalog) : DataContext.Notes.Include(n => n.Author).Include(n => n.Catalog).Where(query); var result = resourceCollectionParameters == null ? await PageList <HmmNote> .CreateAsync(notes, pageIdx, pageSize) : await PageList <HmmNote> .CreateAsync(notes.ApplySort(resourceCollectionParameters.OrderBy), pageIdx, pageSize); return(result); }
public abstract Task <PageList <T> > GetEntitiesAsync(ResourceCollectionParameters resourceCollectionParameters = null);
public abstract PageList <T> GetEntities(ResourceCollectionParameters resourceCollectionParameters = null);
public PageList <NoteRender> GetEntities(Expression <Func <NoteRender, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { return(LookupRepo.GetEntities(query, resourceCollectionParameters)); }
public async Task <PageList <NoteRender> > GetEntitiesAsync(Expression <Func <NoteRender, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var renders = await LookupRepo.GetEntitiesAsync(query, resourceCollectionParameters); return(renders); }
public async Task <PageList <NoteRender> > GetEntitiesAsync(Expression <Func <NoteRender, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { try { var renders = await _dataSource.GetEntitiesAsync(query, resourceCollectionParameters); return(renders); } catch (Exception ex) { ProcessResult.WrapException(ex); return(null); } }
/// <summary> /// The asynchronous version of <see cref="GetNotes"/> /// </summary> /// <param name="entity">The entity which used to get type and figure out the catalog</param> /// <param name="resourceCollectionParameters">The page information of the resource collection</param> /// <returns>The notes which belongs to entity type</returns> protected async Task <PageList <HmmNote> > GetNotesAsync(T entity, Expression <Func <HmmNote, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var catId = await entity.GetCatalogIdAsync(LookupRepo); var author = await LookupRepo.GetEntityAsync <Author>(DefaultAuthor.Id); var hasValidAuthor = DefaultAuthor != null && author != null; switch (hasValidAuthor) { case false: ProcessResult.AddErrorMessage("Cannot find default author", true); return(null); default: PageList <HmmNote> notes; if (query != null) { var finalExp = query.And(n => n.Author.Id == DefaultAuthor.Id && n.Catalog.Id == catId); notes = await NoteManager.GetNotesAsync(finalExp, false, resourceCollectionParameters); } else { notes = await NoteManager.GetNotesAsync(n => n.Author.Id == DefaultAuthor.Id && n.Catalog.Id == catId, false, resourceCollectionParameters); } return(notes); } }
public PageList <NoteCatalog> GetEntities(Expression <Func <NoteCatalog, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { try { var catalogs = _dataSource.GetEntities(query, resourceCollectionParameters); return(catalogs); } catch (Exception ex) { ProcessResult.WrapException(ex); return(null); } }
public async Task <PageList <Author> > GetEntitiesAsync(Expression <Func <Author, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { try { var authors = await _authorRepo.GetEntitiesAsync(query, resourceCollectionParameters); return(authors); } catch (Exception ex) { ProcessResult.WrapException(ex); return(null); } }
public PageList <Subsystem> GetEntities(Expression <Func <Subsystem, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { try { var sys = _dataSource.GetEntities(query, resourceCollectionParameters); return(sys); } catch (Exception ex) { ProcessResult.WrapException(ex); return(null); } }
public async Task <PageList <Author> > GetEntitiesAsync(Expression <Func <Author, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var authors = await _lookupRepo.GetEntitiesAsync(query, resourceCollectionParameters); return(authors); }
public async Task <PageList <Subsystem> > GetEntitiesAsync(Expression <Func <Subsystem, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var systems = await LookupRepo.GetEntitiesAsync(query, resourceCollectionParameters); return(systems); }
public static List <Link> CreatePaginationLinks <T>(this PageList <T> records, string routName, ActionContext context, LinkGenerator linkGen, ResourceCollectionParameters resourceCollectionParameters) { var links = new List <Link>(); if (context == null || linkGen == null) { return(links); } var orderBy = resourceCollectionParameters != null ? resourceCollectionParameters.OrderBy : string.Empty; var fields = resourceCollectionParameters != null ? resourceCollectionParameters.Fields : string.Empty; links.Add(new Link() { Title = routName, Rel = "self", Href = linkGen.GetUriByRouteValues(context.HttpContext, routName, new { pageNumber = records.CurrentPage, records.PageSize, orderBy, fields }), Method = "Get" }); if (records.HasPrevPage) { links.Add(new Link() { Title = routName, Rel = "prev_page", Href = linkGen.GetUriByRouteValues(context.HttpContext, routName, new { pageNumber = records.CurrentPage - 1, pageSize = records.PageSize, orderBy, fields }), Method = "Get" }); } if (records.HasNextPage) { links.Add(new Link() { Title = routName, Rel = "next_page", Href = linkGen.GetUriByRouteValues(context.HttpContext, routName, new { pageNumber = records.CurrentPage + 1, pageSize = records.PageSize, orderBy, fields }), Method = "Get" }); } return(links); }
public async Task <PageList <T> > GetEntitiesAsync <T>(Expression <Func <T, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var(pageIdx, pageSize) = resourceCollectionParameters.GetPaginationTuple(); var entities = GetQueryableEntities <T>(); var result = query == null ? await PageList <T> .CreateAsync(entities, pageIdx, pageSize) : await PageList <T> .CreateAsync(entities.Where(query), pageIdx, pageSize); return(result); }