示例#1
0
        public static void DisplayValue(TextBlock obj, MediaRating rating, double ratio)
        {
            RatingConverter        Conv      = new RatingConverter();
            RatingToColorConverter ColorConv = new RatingToColorConverter();
            double?Value = rating.GetValue(ratio);

            obj.Text       = Conv.Convert(Value, typeof(string), -1, null).ToString();
            obj.Foreground = (SolidColorBrush)ColorConv.Convert(Value, typeof(SolidColorBrush), null, null);
        }
示例#2
0
        public async Task <List <RatingDto> > GetRatingsByUserAsync(Guid id)
        {
            List <RatingDto> ratings = RatingConverter.Convert(_context.Ratings.Where(x => x.UserId == id).ToList());

            foreach (RatingDto rating in ratings)
            {
                rating.ItemName = _context.Items.FirstOrDefaultAsync(x => x.Id == rating.ItemId).Result.Name;
            }
            return(ratings);
        }
示例#3
0
        public async Task <RatingDto> UpdateAsync(Rating rating)
        {
            var RATING = await _context.Ratings.FirstOrDefaultAsync(x => x.Id == rating.Id);

            RATING.Star = rating.Star;

            _context.Ratings.Update(RATING);
            await _context.SaveChangesAsync();

            return(RatingConverter.Convert(RATING));
        }
示例#4
0
        public async Task <RatingDto> CreateAsync(Rating rating)
        {
            //var RATING
            var R = await _context.Ratings.FirstOrDefaultAsync(x => x.UserId == rating.UserId && x.ItemId == rating.ItemId);

            if (R == null)
            {
                var result = await _context.Ratings.AddAsync(rating);

                await _context.SaveChangesAsync();

                return(RatingConverter.Convert(result.Entity));
            }
            else
            {
                R.Star = rating.Star;
                return(await this.UpdateAsync(R));
            }
        }
示例#5
0
        private void DisplayData()
        {
            DisplayValue(PMText, business.PM, Ratio);
            DisplayValue(PFText, business.PF, Ratio);
            DisplayValue(EMText, business.EM, Ratio);
            DisplayValue(EFText, business.EF, Ratio);
            DisplayValue(SMText, business.SM, Ratio);
            DisplayValue(SFText, business.SF, Ratio);
            DisplayValue(LoveText, business.Love, Ratio);
            DisplayValue(EgolessText, business.Egoless, Ratio);
            DisplayValue(Custom1Text, business.Custom1, Ratio);
            DisplayValue(Custom2Text, business.Custom2, Ratio);

            // Display intensity.
            RatingConverter        Conv      = new RatingConverter();
            RatingToColorConverter ColorConv = new RatingToColorConverter();
            double?IntensityValue            = business.GetIntensity();

            IntensityText.Text       = Conv.Convert(IntensityValue, typeof(string), null, null).ToString();
            IntensityText.Foreground = (SolidColorBrush)ColorConv.Convert(IntensityValue, typeof(SolidColorBrush), null, null);
        }