예제 #1
0
        private List<Review> GetReviews()
        {
            var feedbacks =
                context.Feedbacks.Include("SubmittedTo").Include("SubmittedBy").Include("FeedbackType").Where(
                    f => f.SubmittedTo.Username == "SW\\hmeydac").OrderByDescending(f => f.SubmittedDate).ToList();

            var feedbackModels = new List<Models.Feedback>();

            feedbacks.ForEach(f => feedbackModels.Add(Mapper.Map<Models.Feedback>(f)));

            var groups = feedbackModels.GroupBy(f => f.WeekYear);
            var reviews = new List<Models.Review>();
            foreach (var group in groups)
            {
                var review = new Review { WeekYear = @group.Key };
                review.Feedbacks.AddRange(@group);
                reviews.Add(review);
            }
            return reviews;
        }
예제 #2
0
        private List<Review> GetSubmittedReviews(int employeeId, DateTime date)
        {
            var startWeekDay = this.GetStartWeekDay(date);
            var endWeekDay = this.GetEndWeekDay(date);
            var feedbacks =
                context.Feedbacks.Include("SubmittedTo").Include("SubmittedBy").Include("FeedbackType").Where(
                    f => f.SubmittedBy.Username == "SW\\hmeydac" && f.SubmittedTo.Id == employeeId && f.SubmittedDate >= startWeekDay && f.SubmittedDate <= endWeekDay).OrderByDescending(f => f.SubmittedDate).ToList();

            var feedbackModels = new List<Models.Feedback>();

            feedbacks.ForEach(f => feedbackModels.Add(Mapper.Map<Models.Feedback>(f)));

            var groups = feedbackModels.GroupBy(f => f.WeekYear);
            var reviews = new List<Models.Review>();
            foreach (var group in groups)
            {
                var review = new Review { WeekYear = @group.Key };
                review.Feedbacks.AddRange(@group);
                reviews.Add(review);
            }
            return reviews;
        }