//private void BuildStats(IEnumerable<AverageRatingValue> stats, XNamespace ns, string id) //{ // foreach (var stat in stats) // { // // var prodId = MatchProdct(id); // if (prodId.IsNullOrEmpty()) // { continue; } // var ratingMark = stat.AverageRating; // if (ratingMark.IsNullOrEmpty()) // { continue; } // var ratingType = BuildRatingType(stat.RatingDimension.Label); // if (ratingType == null) // { continue; } // var rating = new Rating // { // Mark = (int)Convert.ToDecimal(ratingMark), // Product = Guid.Parse(prodId), // RatingType = ratingType // }; // Ratings.Add(rating); // } //} //private string MatchProdct(string id) //{ // var productId = id.IsNullOrEmpty() ? "" : id; // //var product = ProductItems.FirstOrDefault(x => x.Ean == productId); // //return product != null ? product.ItemId.ToString() : ""; //} private RatingType BuildRatingType(string ratingValue) { var ratingValueField = ratingValue.IsNullOrEmpty() ? "" : ratingValue; var rating = RatingItems.FirstOrDefault(x => x.Name.Equals(ratingValueField, StringComparison.CurrentCultureIgnoreCase)); var ratingType = rating != null?rating.GetItem().GlassCast <RatingType>() : null; //_sitecoreService.Map(rating); return(ratingType); }
private static string GetRatingItems(RatingItems ratingItems) { List <string> list = new List <string>(); if ((ratingItems & RatingItems.SemsSubject) == RatingItems.SemsSubject) { list.Add("學期科目成績"); } if ((ratingItems & RatingItems.SemsScore) == RatingItems.SemsScore) { list.Add("學期學業成績"); } if ((ratingItems & RatingItems.SemsMoral) == RatingItems.SemsMoral) { list.Add("學期德行成績"); } if ((ratingItems & RatingItems.YearSubject) == RatingItems.YearSubject) { list.Add("學年科目成績"); } if ((ratingItems & RatingItems.YearScore) == RatingItems.YearScore) { list.Add("學年學業成績"); } if ((ratingItems & RatingItems.YearMoral) == RatingItems.YearMoral) { list.Add("學年德行成績"); } return(string.Join(",", list.ToArray())); }
private bool RequireRating(RatingItems rating) { return((RatingParams.RatingItems & rating) == rating); }