示例#1
0
        protected void RateControl_Rate(object sender, RateEventArgs e)
        {
            var          recipeData = this.data.Recipes.Find(recipeId);
            RecipeRating rating     = new RecipeRating()
            {
                RecipeID = recipeId,
                UserID   = this.loggedUserId,
                Rating   = e.RateValue,
                RatedOn  = DateTime.Now
            };

            this.data.RecipeRatings.Add(rating);
            this.data.SaveChanges();

            var control      = sender as Rates;
            var recipeRating = 0.0;

            if (recipeData.Ratings.Count > 0)
            {
                recipeRating = (double)recipeData.Ratings.Sum(r => r.Rating) / recipeData.Ratings.Count;
            }

            this.RateControl.Value        = Convert.ToInt32(Math.Ceiling(recipeRating));
            this.RateControl.UserVote     = true;
            this.RateControl.RatingsCount = recipeData.Ratings.Count;
            this.RateControl.mustUpdate   = true;
        }
示例#2
0
        private void OnRateBlog(object sender, RateEventArgs r)
        {
            var User = r.Context.User;

            if (User.Identity.IsAuthenticated && _cache.Get <bool?>(ExpUtil.HasRatedCacheKey + User.Identity.Name.ToLower()) != true)
            {
                var expUtil = r.Context.RequestServices.GetService <ExpUtil>();
                if (expUtil.setRateDateAddExp(User.Identity.Name))
                {
                    r.Context.Items["QuestMsg"] = firstRateNotice;
                    _cache.Set(ExpUtil.HasRatedCacheKey + User.Identity.Name.ToLower(), true, DateTime.Today.AddDays(1));
                }
            }
        }
示例#3
0
        public async Task UpdateBlogRateAsync(RateEventArgs e)
        {
            using (var scope = _scopeFactory.CreateScope())
            {
                var util   = scope.ServiceProvider.GetService <RatingUtil>();
                var rating = util.GetRating(e.Model.BlogID).Total;
                var result = await _client.UpdateAsync <BlogIndexed, object>(DocumentPath <BlogIndexed> .Id(e.Model.BlogID), ud => ud.Doc(new { rating }).Refresh(Elasticsearch.Net.Refresh.True));

                if (!result.IsValid)
                {
                    _logger.LogError(result.DebugInformation);
                    var db   = scope.ServiceProvider.GetService <BlogContext>();
                    var blog = await db.Blogs.FindAsync(e.Model.BlogID);

                    if (blog != null)
                    {
                        await AddOrUpdateBlogAsync(new BlogEventArgs(blog));
                    }
                }
            }
        }
示例#4
0
文件: Form1.cs 项目: wiewioraseb/edu
        protected void RateComboBox_SelectedIndexChanged(object sender, RateEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Rate " + ((ComboBox)sender).Text + "  from RateComboBox recieved in parent,  id: " + e.Id + " model: " + e.Model);

            try
            {
                CarsData.UpdateCar("UPDATE cars SET sum_rates=sum_rates+" + ((ComboBox)sender).Text + " WHERE id=" + e.Id);
                CarsData.UpdateCar("UPDATE cars SET no_rates=no_rates+1 WHERE id=" + e.Id);

                string sum_rates = CarsData.GetCars("SELECT sum_rates FROM cars WHERE id=" + e.Id).Rows[0].ItemArray[0].ToString();
                string no_rates  = CarsData.GetCars("SELECT no_rates FROM cars WHERE id=" + e.Id).Rows[0].ItemArray[0].ToString();

                float  float_avg_rate = (float)Int32.Parse(sum_rates) / Int32.Parse(no_rates);
                string avg_rate       = float_avg_rate.ToString().Replace(',', '.');
                System.Diagnostics.Debug.WriteLine("avg_rate: " + avg_rate + " sum_rates: " + sum_rates + " no_rates: " + no_rates);


                CarsData.UpdateCar("UPDATE cars SET avg_rate=" + avg_rate + " WHERE id=" + e.Id);

                RateCar.service.GetDataService.Most3DataTableFromHost =
                    CarsData.GetCars
                        ("SELECT id, brand, model, car_engine, production_year, avg_rate, no_rates FROM cars ORDER BY no_rates DESC LIMIT 3");

                RateCar.service.GetDataService.Best3DataTableFromHost =
                    CarsData.GetCars
                        ("SELECT id, brand, model, car_engine, production_year, avg_rate, no_rates FROM cars ORDER BY avg_rate DESC LIMIT 3");

                this.cars1BindingSource.DataSource = CarsData.GetCars();

                lastRatedCarLabel.Text = e.Brand + " " + e.Model + " oceniono na: " + ((ComboBox)sender).Text;
            }
            catch (SqlException ex)
            {
                System.Diagnostics.Debug.WriteLine("SQL EXCEPTION when rating car : " + ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#5
0
文件: Job.cs 项目: ChloeKurumi/gmgard
 public static Job UpdateBlogRate(RateEventArgs updateBlogRateArgs)
 => new Job
 {
     JobType = JobType.UpdateBlogRate, UpdateBlogRateArgs = updateBlogRateArgs
 };
 protected virtual void OnRateEvent(RateEventArgs e) => RateEvent?.Invoke(this, e);
示例#7
0
 private void SearchControl_RateEvent(object sender, RateEventArgs e)
 => RateServices.Instance.RateMusic(e.ElementRatedMID, e.Type);