/// <summary> /// Initializes a new instance of <see cref="MetricsAdvisor.MetricPeriodFeedback"/> for mocking purposes. /// </summary> /// <param name="id">Sets the <see cref="MetricFeedback.Id"/> property.</param> /// <param name="createdOn">Sets the <see cref="MetricFeedback.CreatedOn"/> property.</param> /// <param name="userPrincipal">Sets the <see cref="MetricFeedback.UserPrincipal"/> property.</param> /// <param name="metricId">Sets the <see cref="MetricFeedback.MetricId"/> property.</param> /// <param name="dimensionKey">Sets the <see cref="MetricFeedback.DimensionKey"/> property.</param> /// <param name="periodType">Sets the <see cref="MetricPeriodFeedback.PeriodType"/> property.</param> /// <param name="periodValue">Sets the <see cref="MetricPeriodFeedback.PeriodValue"/> property.</param> /// <returns>A new instance of <see cref="MetricsAdvisor.MetricPeriodFeedback"/> for mocking purposes.</returns> public static MetricPeriodFeedback MetricPeriodFeedback(string id = null, DateTimeOffset?createdOn = null, string userPrincipal = null, string metricId = null, DimensionKey dimensionKey = null, MetricPeriodType periodType = default, int periodValue = default) { Dictionary <string, string> dimensions = dimensionKey?.ToDictionary(key => key.Key, key => key.Value); FeedbackFilter filter = new FeedbackFilter(dimensions); PeriodFeedbackValue feedbackValue = new PeriodFeedbackValue(periodType, periodValue); return(new MetricPeriodFeedback(MetricFeedbackKind.Period, id, createdOn, userPrincipal, metricId, filter, feedbackValue)); }
/// <summary> /// Initializes a new instance of <see cref="MetricsAdvisor.MetricAnomalyFeedback"/> for mocking purposes. /// </summary> /// <param name="id">Sets the <see cref="MetricFeedback.Id"/> property.</param> /// <param name="createdOn">Sets the <see cref="MetricFeedback.CreatedOn"/> property.</param> /// <param name="userPrincipal">Sets the <see cref="MetricFeedback.UserPrincipal"/> property.</param> /// <param name="metricId">Sets the <see cref="MetricFeedback.MetricId"/> property.</param> /// <param name="dimensionKey">Sets the <see cref="MetricFeedback.DimensionKey"/> property.</param> /// <param name="startsOn">Sets the <see cref="MetricAnomalyFeedback.StartsOn"/> property.</param> /// <param name="endsOn">Sets the <see cref="MetricAnomalyFeedback.EndsOn"/> property.</param> /// <param name="anomalyValue">Sets the <see cref="MetricAnomalyFeedback.AnomalyValue"/> property.</param> /// <param name="detectionConfigurationId">Sets the <see cref="MetricAnomalyFeedback.DetectionConfigurationId"/> property.</param> /// <param name="detectionConfigurationSnapshot">Sets the <see cref="MetricAnomalyFeedback.DetectionConfigurationSnapshot"/> property.</param> /// <returns>A new instance of <see cref="MetricsAdvisor.MetricAnomalyFeedback"/> for mocking purposes.</returns> public static MetricAnomalyFeedback MetricAnomalyFeedback(string id = null, DateTimeOffset?createdOn = null, string userPrincipal = null, string metricId = null, DimensionKey dimensionKey = null, DateTimeOffset startsOn = default, DateTimeOffset endsOn = default, AnomalyValue anomalyValue = default, string detectionConfigurationId = null, AnomalyDetectionConfiguration detectionConfigurationSnapshot = null) { Dictionary <string, string> dimensions = dimensionKey?.ToDictionary(key => key.Key, key => key.Value); FeedbackFilter filter = new FeedbackFilter(dimensions); AnomalyFeedbackValue feedbackValue = new AnomalyFeedbackValue(anomalyValue); return(new MetricAnomalyFeedback(MetricFeedbackKind.Anomaly, id, createdOn, userPrincipal, metricId, filter, startsOn, endsOn, feedbackValue, detectionConfigurationId, detectionConfigurationSnapshot)); }
/// <summary> /// Initializes a new instance of <see cref="MetricsAdvisor.MetricCommentFeedback"/> for mocking purposes. /// </summary> /// <param name="id">Sets the <see cref="MetricFeedback.Id"/> property.</param> /// <param name="createdOn">Sets the <see cref="MetricFeedback.CreatedOn"/> property.</param> /// <param name="userPrincipal">Sets the <see cref="MetricFeedback.UserPrincipal"/> property.</param> /// <param name="metricId">Sets the <see cref="MetricFeedback.MetricId"/> property.</param> /// <param name="dimensionKey">Sets the <see cref="MetricFeedback.DimensionKey"/> property.</param> /// <param name="startsOn">Sets the <see cref="MetricCommentFeedback.StartsOn"/> property.</param> /// <param name="endsOn">Sets the <see cref="MetricCommentFeedback.EndsOn"/> property.</param> /// <param name="comment">Sets the <see cref="MetricCommentFeedback.Comment"/> property.</param> /// <returns>A new instance of <see cref="MetricsAdvisor.MetricCommentFeedback"/> for mocking purposes.</returns> public static MetricCommentFeedback MetricCommentFeedback(string id = null, DateTimeOffset?createdOn = null, string userPrincipal = null, string metricId = null, DimensionKey dimensionKey = null, DateTimeOffset?startsOn = null, DateTimeOffset?endsOn = null, string comment = null) { Dictionary <string, string> dimensions = dimensionKey?.ToDictionary(key => key.Key, key => key.Value); FeedbackFilter filter = new FeedbackFilter(dimensions); CommentFeedbackValue feedbackValue = new CommentFeedbackValue(comment); return(new MetricCommentFeedback(MetricFeedbackKind.Comment, id, createdOn, userPrincipal, metricId, filter, startsOn, endsOn, feedbackValue)); }
/// <summary> /// Initializes a new instance of the <see cref="ReviewsViewModel" /> class. /// </summary> /// <param name="book">The book.</param> /// <param name="feedbackService">The feedback service.</param> /// <param name="authService">The authentication service.</param> public ReviewsViewModel(DetailedBookDto book, IFeedbackService feedbackService, IAuthenticationService authService) { this.authService = authService; var feedbackFilter = new FeedbackFilter { BookId = book.Id }; this.Reviews = new ObservableServiceCollection <BookFeedbackDto, FeedbackFilter, IFeedbackService>(feedbackService, feedbackFilter); }
/// <summary> /// Gets the feedback, filtered by <see cref="filter" />. /// </summary> /// <param name="filter">The filter.</param> /// <returns></returns> /// <exception cref="ArgumentException">Missing Book ID!</exception> public async Task <IPaginatedEnumerable <BookFeedbackDto> > GetFeedback(FeedbackFilter filter) { if (filter.BookId == 0) { throw new ArgumentException("Missing Book ID!", nameof(filter.BookId)); } var request = new RequestBuilder() .BaseUri(this.Url) .AddQuery(nameof(filter.BookId), filter.BookId) .AddQuery(nameof(filter.Skip), filter.Skip) .AddQuery(nameof(filter.Take), filter.Take); if (!string.IsNullOrEmpty(filter.Search)) { request.AddQuery(nameof(filter.Search), filter.Search); } return(await this.ExecuteAndParse <PaginatedEnumerable <BookFeedbackDto> >(request)); }
public string SubmitMark(FeedbackFilter filter) { try { if (!ListCache.Instance.Dictionary.ContainsKey(filter.vid)) return NoVideos(); var root = new XElement("succed", new XElement("mark", filter.mark) ); return root.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoVideos(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
public string SubmitMark(FeedbackFilter filter) { try { if (!ListCache.Instance.Dictionary.ContainsKey(filter.vid)) { return(NoVideos()); } var root = new XElement("succed", new XElement("mark", filter.mark) ); return(root.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoVideos()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
public async Task <IPaginatedEnumerable <BookFeedbackDto> > GetByFilter(FeedbackFilter filter) { if (!(filter.BookId > 0)) { throw new BadRequestException($"BookId was less than 0, did you forget to supply a bookid?"); } var bookId = filter.BookId; var skip = filter.Skip; var take = filter.Take; var feedbacks = this.Context.BookFeedback.Where(x => x.BookId == bookId).Include(x => x.Person).OrderBy(x => x.BookId).ThenBy(x => x.PersonId); var feedbackAmount = feedbacks.Count(); var feedbacksOrdered = feedbacks.Skip(skip); feedbacksOrdered = feedbacksOrdered.Take(take); var feedbacksList = await feedbacksOrdered.ToListAsync(); return(new PaginatedEnumerable <BookFeedbackDto>(feedbacksList.Select(x => x.ToDto()), feedbackAmount)); }
/// <summary> /// Gets the items, using the provided Filter. /// </summary> /// <param name="filter">The filter.</param> /// <returns></returns> public async Task <IPaginatedEnumerable <BookFeedbackDto> > GetItems(FeedbackFilter filter) { return(await this.api.GetFeedback(filter)); }
public async Task <IHttpActionResult> Get([FromUri] FeedbackFilter filter = null) { filter = filter ?? new FeedbackFilter(); return(await this.Try(() => this._bookFeedbackRepository.GetByFilter(filter))); }