Exemplo n.º 1
0
        public void FillProperties()
        {
            // Arrange
            var OverallRatings = new List <int>();
            var RevisionDates  = new List <DateTime>();
            //var UseDates = new List<DateTime>();
            var reviewCount = 0;

            // Get data
            var db = Current.DB;

            foreach (var review in db.InstrumentReviews.Where(rev => rev.InstrumentID == this.InstrumentID))
            {
                var LatestRevision = db.InstrumentReviewRevisions.Where(revision => revision.ReviewID == review.ReviewID).OrderByDescending(revision => revision.RevisionDate).Take(1).ToList()[0];
                OverallRatings.Add(LatestRevision.RatingGeneral);
                RevisionDates.Add(LatestRevision.RevisionDate);
                //UseDates.Add(LatestRevision.LastUseDate);
                reviewCount++;
            }

            // Process
            AverageOverallRating     = OverallRatings.Count > 0 ? ((int)Math.Round(OverallRatings.Average())) : 0;
            LatestReviewRevisionDate = RevisionDates.Count > 0 ? (DateTime?)RevisionDates.Max() : null; //this.SubmissionDate;
            //LatestUseDate = UseDates.Count > 0 ? UseDates.Max() : this.SubmissionDate;
            NumberOfReviews = reviewCount;

            // Generate Title and UrlSlug
            Title = "";
            if (this.Brand.HasValue())
            {
                Title += this.Brand.Trim() + " ";
            }
            if (this.Model.HasValue())
            {
                Title += this.Model.Trim() + " ";
            }
            if (this.InstrumentType != null && this.InstrumentType.Name.HasValue())
            {
                Title += this.InstrumentType.Name.Trim() + ": ";
            }
            if (this.StreetAddress.HasValue())
            {
                Title += DisplayedStreetAddress.GetValueOrDefault(StreetAddress).Trim() + " ";
            }
            Title   = Title.Trim();
            UrlSlug = HtmlUtilities.URLFriendly(Title);

            var listClass = InstrumentClasses.Classes.Where(c => c.Id == Int32.Parse(this.ListingClass)).SingleOrDefault();

            ListingClassDisplay = listClass.DisplayName;
            RentalSubmission    = (listClass.Name == "Rent");
        }
Exemplo n.º 2
0
 public void PrepareRender()
 {
     DisplayedStreetAddress = DisplayedStreetAddress.GetValueOrDefault(StreetAddress);
     DisplayedLat           = DisplayedLat.GetValueOrDefault(Lat);
     DisplayedLong          = DisplayedLong.GetValueOrDefault(Long);
 }