Пример #1
0
        public ActionResult TopDialogFeedback()
        {
            var totalFeedback = DataAccessLayer.Get<Review>();

            var list = new List<Feedback.Entry>();
            int counter = 0;
            while (true)
            {
                var user = DataAccessLayer.TopRandom<PromouterUser>(3);
                foreach (var promouterUser in user)
                {
                    var review = DataAccessLayer.Get<Review>(x => x.AuthorId == promouterUser.Id);
                    if (review.Any())
                    {
                        var binder = new FeedbackToReview(DataAccessLayer);
                        var entry = new Feedback.Entry();
                        binder.InverseLoad(review.First(), entry);

                        list.Add(entry);
                        if (list.Count == 3)
                            break;
                    }
                }

                if (list.Count == 3)
                    break;

                counter++;

                if (counter > 1000)
                    break;

            }

            var tuple = new Tuple<ICollection<Feedback.Entry>, int>(list,totalFeedback.Count());

            return PartialView(tuple);
        }
Пример #2
0
        private Feedback prepareFeedbacks(IEnumerable<Review> feedbacks, int count = 0)
        {
            var binder = new FeedbackToReview(DataAccessLayer);
            var collection = count > 0 ? feedbacks.Take(count) : feedbacks;
            return new Feedback
            {
                Count = feedbacks.Count(),
                Entries = collection.Select(x => {
                    var result = new Feedback.Entry();
                    binder.InverseLoad(x, result);
                    return result;
                }).ToList(),

            };
        }