本文整理汇总了C#中Rating类的典型用法代码示例。如果您正苦于以下问题:C# Rating类的具体用法?C# Rating怎么用?C# Rating使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rating类属于命名空间,在下文中一共展示了Rating类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRatingToRecipe
public void AddRatingToRecipe(Rating rate, Recipe r, User u)
{
SqlConnection con = CreateConnection();
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "AddRatingToRecipe";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@recipeID", r.Id);
cmd.Parameters.AddWithValue("@userID", u.Id);
cmd.Parameters.AddWithValue("@rating", rate);
cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
throw /*ex*/;
}
finally
{
if (con != null)
{
con.Close();
}
}
}
示例2: UpdateProductRating
public void UpdateProductRating(Rating r)
{
entities.Rating.Attach(GetRating(r.ProductID,r.Username));
entities.Rating.ApplyCurrentValues(r);
entities.SaveChanges();
}
示例3: Picture
internal Picture(string name, string displayName, Rating rating, IEnumerable<Category> categories)
{
this.name = name;
this.displayName = displayName;
this.rating = rating;
this.categories = ImmutableHashSet.Create(categories);
}
示例4: Search
public Task<List<ImageResult>> Search(string search, Rating rating = Rating.Strict, ResultSize resultSize = ResultSize.Twenty, int offset = 0)
{
return Task.Run<List<ImageResult>>(() =>
{
return new List<ImageResult>();
});
}
示例5: RecipeRater
public RecipeRater(IKPCContext context, Recipe recipe, Rating rating)
{
this.context = context;
this.newRatings = new Dictionary<Recipe, Rating>();
this.newRatings.Add(recipe, rating);
}
示例6: CreateTermLoan
public static Loan CreateTermLoan(decimal amount, DateTime start, DateTime maturity, Rating riskRating, IRiskFactor factors)
{
var loan = new Loan(null, maturity, amount, amount, factors, null);
loan.riskRating = riskRating;
loan.start = start;
return loan;
}
示例7: Reset
public void Reset()
{
m_LastScore = Rating.None;
m_Score = Rating.None;
m_LastTotalScore = 0;
m_TotalScore = 0;
}
示例8: Comment
/// <summary>
/// Full constructor.
/// </summary>
public Comment(Rating rating, string text, User fromUser, Item item)
{
this.rating = rating;
this.text = text;
this.fromUser = fromUser;
this.item = item;
}
示例9: CreateRating
public ActionResult CreateRating([DataSourceRequest]DataSourceRequest request, IEnumerable<AdministrationRatingsViewModel> models)
{
var result = new List<AdministrationRatingsViewModel>();
if (this.ModelState.IsValid && models != null)
{
foreach (var model in models)
{
var ratingUser = this.users.GetByUsername(model.UserName).FirstOrDefault();
var petToUpdate = this.pets.GetByIntId(model.PetId).FirstOrDefault();
if (ratingUser != null && petToUpdate != null)
{
var newRating = new Rating { RatingValue = model.RatingValue, PetId = model.PetId, Author = ratingUser };
this.ratings.Add(newRating);
petToUpdate.CurrentRating = petToUpdate.Ratings.Average(r => r.RatingValue);
this.pets.Update(petToUpdate);
model.CreatedOn = newRating.CreatedOn;
model.Id = newRating.Id;
result.Add(model);
}
}
return this.Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
return null;
}
示例10: Execute
public bool Execute ()
{
this.CreateDialog ("rating_filter_dialog");
if (query.RatingRange != null) {
minrating_value = (int) query.RatingRange.MinRating;
maxrating_value = (int) query.RatingRange.MaxRating;
}
minrating = new Rating (minrating_value);
maxrating = new Rating (maxrating_value);
minrating_hbox.PackStart (minrating, false, false, 0);
maxrating_hbox.PackStart (maxrating, false, false, 0);
Dialog.TransientFor = parent_window;
Dialog.DefaultResponse = ResponseType.Ok;
ResponseType response = (ResponseType) this.Dialog.Run ();
bool success = false;
if (response == ResponseType.Ok) {
query.RatingRange = new RatingRange ((uint) minrating.Value, (uint) maxrating.Value);
success = true;
}
this.Dialog.Destroy ();
return success;
}
示例11: GravatarImage
/// <summary>
/// Returns a Globally Recognised Avatar as an <img /> - http://gravatar.com
/// </summary>
/// <param name="emailAddress">Email Address for the Gravatar</param>
/// <param name="defaultImage">Default image if user hasn't created a Gravatar</param>
/// <param name="size">Size in pixels (default: 80)</param>
/// <param name="defaultImageUrl">URL to a custom default image (e.g: 'Url.Content("~/images/no-grvatar.png")' )</param>
/// <param name="forceDefaultImage">Prefer the default image over the users own Gravatar</param>
/// <param name="rating">Gravatar content rating (note that Gravatars are self-rated)</param>
/// <param name="forceSecureRequest">Always do secure (https) requests</param>
public static HtmlString GravatarImage(
this HtmlHelper htmlHelper,
string emailAddress,
int size = 80,
DefaultImage defaultImage = DefaultImage.Default,
string defaultImageUrl = "",
bool forceDefaultImage = false,
Rating rating = Rating.G,
bool forceSecureRequest = false)
{
var imgTag = new TagBuilder("img");
emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower();
imgTag.Attributes.Add("src",
string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "https" : "http",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "secure" : "www",
GetMd5Hash(emailAddress),
size.ToString(),
"&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? HttpUtility.UrlEncode(defaultImageUrl) : defaultImage.GetDescription()),
forceDefaultImage ? "&f=y" : "",
"&r=" + rating.GetDescription()
)
);
//imgTag.Attributes.Add("class", "gravatar");
imgTag.Attributes.Add("class", "uk-border-rounded");
imgTag.Attributes.Add("alt", "Gravatar image");
return new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing));
}
示例12: Rate
public double Rate(int clinicId, string userId, int ratingValue)
{
var rating = this.ratings.All().FirstOrDefault(x => x.AuthorId == userId && x.ClinicId == clinicId);
if (rating == null)
{
rating = new Rating()
{
AuthorId = userId,
ClinicId = clinicId,
Value = ratingValue
};
this.ratings.Add(rating);
}
else
{
rating.Value = ratingValue;
}
this.ratings.Save();
double clinicRating = this.ratings
.All()
.Where(x => x.ClinicId == clinicId)
.Average(x => x.Value);
return clinicRating;
}
示例13: Gravatar
/// <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);
}
示例14: AddRating
public void AddRating(int postId, byte value, string authorId)
{
var newRating = new Rating { PostId = postId, Value = value, AuthorId = authorId };
this.ratings.Add(newRating);
this.ratings.SaveChanges();
}
示例15: PointsExchanged
public static int PointsExchanged(Rating winnerRating, Rating loserRating)
{
var difference = (double)loserRating.Value - winnerRating.Value;
var expected = 1 / (1 + (Math.Pow(10,(difference/Volatility))));
var exchanged = (Int32)Math.Round((Factor * (1 - expected)), MidpointRounding.AwayFromZero);
return exchanged;
}