public List <Feedback> Get(string privateToken, Rating?rating, int page, int pageSize) { var collectionService = dbContext.ServiceCollection; var builderFilterService = Builders <Service> .Filter; var filterPrivateToken = builderFilterService.Eq(x => x.PrivateToken, privateToken); var publicToken = collectionService.Find(filterPrivateToken).Single(); var collectionFeedback = dbContext.FeedbackCollection; var builderFilterFeedbackByRating = Builders <Feedback> .Filter; if (rating != null) { var filterRating = builderFilterFeedbackByRating.Eq(x => (int)x.Rating, (int)rating) & builderFilterFeedbackByRating.Eq(x => x.PublicToken, publicToken.PublicToken); var allFeedback = collectionFeedback.Find(filterRating).ToList().OrderByDescending(x => x.InstantUtc); if (page == 0 && pageSize == 0) { return(allFeedback.ToList()); } return(allFeedback.Skip((page - 1) * pageSize).Take(pageSize).ToList()); } else { var filterRating = builderFilterFeedbackByRating.Eq(x => x.PublicToken, publicToken.PublicToken); var allFeedback = collectionFeedback.Find(filterRating).ToList().OrderByDescending(x => x.InstantUtc); if (page == 0 && pageSize == 0) { return(allFeedback.ToList()); } return(allFeedback.Skip((page - 1) * pageSize).Take(pageSize).ToList()); } }
/// <summary> /// Gets an img tag of the Gravatar for the supplied specifications. /// </summary> /// <param name="htmlHelper">The HtmlHelper object that does the rendering.</param> /// <param name="email">The email address whose Gravatar should be rendered.</param> /// <param name="size">The size of the rendered Gravatar.</param> /// <param name="defaultImage">The default image to display if no Gravatar exists for the specified <paramref name="email"/>.</param> /// <param name="maxRating">The maximum Gravatar rating to allow for rendered Gravatars.</param> /// <param name="htmlAttributes">Additional attributes to include in the rendered tag.</param> /// <returns>An HTML string of the rendered img tag.</returns> public static MvcHtmlString Gravatar( this HtmlHelper htmlHelper, string email, int?size, string defaultImage, Rating?maxRating, object htmlAttributes ) { return(Gravatar(htmlHelper, email, size, defaultImage, maxRating, DictionaryFromObject(htmlAttributes))); }
public RecipeQuery(RecipeQuery query) { this.Keywords = query.Keywords; this.Rating = query.Rating; if (query.Include != null) this.Include = (Guid[]) query.Include.Clone(); if (query.Exclude != null) this.Exclude = (Guid[]) query.Exclude.Clone(); this.Time = query.Time; this.Photos = query.Photos; this.Sort = query.Sort; this.Direction = query.Direction; }
/// <inheritdoc /> public bool Equals(Rating?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(IsEqual(other)); }
private void SaveUsers(int aerobicCapacity, Rating?fitnessResult) { if (fitnessResult == null) { return; } DatabaseContext.Add(new UserInfo() { Name = userList[userIndex].Name, Age = userList[userIndex].Age, Date = DateTime.Now, Capacity = aerobicCapacity, Fitness = (Rating)fitnessResult, Sex = userList[userIndex].Sex }); }
public RatingViewModel(Rating?r) { this.Rating = r; Rating = r; if (r.HasValue) { Description = r.Value.ToString(); } else { Description = String.Empty; } }
public static string RatingColor(Rating?rating, int?currentIndex = null) { if (!rating.HasValue || currentIndex.HasValue && currentIndex != (int)rating) { return("light"); } return(rating switch { Rating.Undefined => "dark", Rating.Orienting => "danger", Rating.Beginning => "warning", Rating.Proficient => "success", Rating.Advanced => "primary", _ => "light" });
public RecipeQuery(RecipeQuery query) { this.Keywords = query.Keywords; this.Rating = query.Rating; if (query.Include != null) { this.Include = (Guid[])query.Include.Clone(); } if (query.Exclude != null) { this.Exclude = (Guid[])query.Exclude.Clone(); } this.Time = query.Time; this.Photos = query.Photos; this.Sort = query.Sort; this.Direction = query.Direction; }
public IActionResult Update([FromBody] Rating?rating) { var validationError = ValidateRating(rating); if (validationError != null) { return(BadRequest(validationError)); } var updatedRating = ratingsRepository.TryUpdate(rating !); if (updatedRating == null) { return(BadRequest("Rating has not updated")); } return(Ok(updatedRating)); }
private string?ValidateRating(Rating?rating) { if (rating == null) { return("Body is required"); } if (string.IsNullOrEmpty(rating.BookIsbnNumber)) { return("BookIsbnNumber is required"); } if (rating.Value < 0 || rating.Value > 100) { return("Rating should be in [0, 100] range"); } return(null); }
public async Task FetchTVShowDetails_VerifySuccessfulFetchDetails() { var httpclient = new HttpClient(); var tmdbapi = new TMDBapi(httpclient); var tmdb_id = 1408; var expectedGenreCount = 3; var GregoryHouseExists = false; var expectedName = "Gregory House"; Rating expectedRating = Rating.TV_14; Rating?rating = null; var TVShowDetails = await tmdbapi.FetchTVShowDetailsAsync(tmdb_id); Assert.IsNotNull(TVShowDetails); Assert.AreEqual(TVShowDetails.genres.ToList().Count, expectedGenreCount); Assert.IsNotNull(TVShowDetails.credits); Assert.IsNotNull(TVShowDetails.credits.cast); Assert.IsTrue(TVShowDetails.credits.cast.ToList().Count > 0); foreach (var person in TVShowDetails.credits.cast) { if (person.character == expectedName) { GregoryHouseExists = true; break; } } Assert.IsTrue(GregoryHouseExists); Assert.IsNotNull(TVShowDetails.content_ratings); Assert.IsNotNull(TVShowDetails.content_ratings.results); Assert.IsTrue(TVShowDetails.content_ratings.results.ToList().Count > 0); foreach (var country in TVShowDetails.content_ratings.results) { if (country.iso_3166_1 == "US") { rating = Movie.RatingFromString(country.rating); break; } } Assert.IsNotNull(rating); Assert.AreEqual(rating, expectedRating); }
/// <summary> /// Gets an img tag of the Gravatar for the supplied specifications. /// </summary> /// <param name="htmlHelper">The HtmlHelper object that does the rendering.</param> /// <param name="email">The email address whose Gravatar should be rendered.</param> /// <param name="size">The size of the rendered Gravatar.</param> /// <param name="defaultImage">The default image to display if no Gravatar exists for the specified <paramref name="email"/>.</param> /// <param name="maxRating">The maximum Gravatar rating to allow for rendered Gravatars.</param> /// <param name="htmlAttributes">Additional attributes to include in the rendered tag.</param> /// <returns>An HTML string of the rendered img tag.</returns> public static MvcHtmlString Gravatar( this HtmlHelper htmlHelper, string email, int?size, string defaultImage, Rating?maxRating, IDictionary <string, string> htmlAttributes ) { var gravatar = new Gravatar(); gravatar.DefaultImage = defaultImage; if (size.HasValue) { gravatar.Size = size.Value; } if (maxRating.HasValue) { gravatar.MaxRating = maxRating.Value; } return(MvcHtmlString.Create(gravatar.Render(email, htmlAttributes))); }
/// <summary> /// Gets the URI of the Gravatar image for the specifications. /// </summary> /// <param name="urlHelper">The UrlHelper object getting the URI.</param> /// <param name="email">The email whose Gravatar source should be returned.</param> /// <param name="size">The size of the requested Gravatar.</param> /// <param name="defaultImage">The default image to return if no Gravatar is found for the specified <paramref name="email"/>.</param> /// <param name="maxRating">The maximum Gravatar rating to allow for requested images..</param> /// <returns>The URI of the Gravatar for the specifications.</returns> public static string Gravatar(this UrlHelper urlHelper, string email, int?size, string defaultImage, Rating?maxRating) { var gravatar = new Gravatar(); gravatar.DefaultImage = defaultImage; if (size.HasValue) { gravatar.Size = size.Value; } if (maxRating.HasValue) { gravatar.MaxRating = maxRating.Value; } return(gravatar.GetImageSource(email)); }
public UserBuilder WithRating(Rating rating) { _rating = rating; return(this); }