/// <summary> /// Fetches lists of events with optional filters. /// </summary> /// <param name="filter"> /// Search query filter data /// </param> public virtual EventResult GetEvents(EventRequestFilter filter = default(EventRequestFilter)) { var request = new RestRequest(EventsUrlSegment, Method.GET); // Parse filter // ParseEventFilter(request, filter); return(Execute <EventResult>(request)); }
public PageResponse <Event> GetEventPage([FromQuery] int page, [FromQuery] int size) { _logger.LogInformation(LoggingEvents.GetPage, "Getting page {PAGE}", page); string filterString = HttpContext.Request.Query["filter"]; EventRequestFilter filter = JsonConvert.DeserializeObject <EventRequestFilter>(filterString); CorrectUserTime(filter); _logger.LogDebug(LoggingEvents.Filtering, "Getting page {PAGE} FromDate: {FROM} ToDate: {TO}", page, filter.fromDate, filter.toDate); return(_service.GetPage(page, size, filter)); }
private void ParseEventFilter(IRestRequest request, EventRequestFilter filter) { if (filter != null) { if (filter.Name.HasValue()) { request.AddParameter("name", filter.Name); } if (filter.NameStartsWith.HasValue()) { request.AddParameter("nameStartsWith", filter.NameStartsWith); } if (filter.ModifiedSince.HasValue) { request.AddParameter("modifiedSince", filter.ModifiedSince.Value.ToString("yyyy-MM-dd")); } if (filter.Creators.HasValue()) { request.AddParameter("creators", filter.Creators); } if (filter.Characters.HasValue()) { request.AddParameter("characters", filter.Characters); } if (filter.Series.HasValue()) { request.AddParameter("series", filter.Series); } if (filter.Comics.HasValue()) { request.AddParameter("comics", filter.Comics); } if (filter.Stories.HasValue()) { request.AddParameter("stories", filter.Stories); } if (filter.ResultSetOrder.HasValue()) { request.AddParameter("orderBy", filter.ResultSetOrder); } if (filter.Limit.HasValue) { request.AddParameter("limit", filter.Limit.Value); } if (filter.Offset.HasValue) { request.AddParameter("offset", filter.Offset.Value); } } }
/// <summary> /// Fetches lists of events in which a specific comic appears, /// with optional filters. /// </summary> /// <param name="comicId"> /// Comic unique identifier /// </param> /// <param name="filter"> /// Search query filter data /// </param> public virtual EventResult GetComicEvents(string comicId, EventRequestFilter filter = default(EventRequestFilter)) { // Build request url // string requestUrl = string.Format("{0}/{1}/events", ComicsUrlSegment, comicId); var request = new RestRequest(requestUrl, Method.GET); // Parse filter // ParseEventFilter(request, filter); return(Execute <EventResult>(request)); }
private void CorrectUserTime(EventRequestFilter f) { var offset = GetOffset(); if (offset != 0) { if (f.fromDate > DateTime.MinValue && f.toDate < DateTime.MaxValue) { TimeSpan tsOffset = TimeSpan.FromMinutes(-offset); //FromDate f.fromDate = new DateTimeOffset(f.fromDate).ToOffset(tsOffset).DateTime; //ToDate f.toDate = new DateTimeOffset(f.toDate).ToOffset(tsOffset).DateTime; } } }