예제 #1
0
        public void GivenAllPeersHaveProvidedTheReview()
        {
            var reviewId = ScenarioContext.Current.Get <ReviewConfiguration>().Id;

            using (var ctx = new DelayedDatabaseContext()) {
                var reviewConfiguration = ctx.ReviewConfigurations.Find(reviewId);
                ctx.Entry(reviewConfiguration).Collection(c => c.Categories).Load();
                ctx.Entry(reviewConfiguration).Collection(c => c.Peers).Load();
                foreach (var reviewer in reviewConfiguration.Peers)
                {
                    var newFeedback = new ReviewFeedback();
                    foreach (var reviewCategory in reviewConfiguration.Categories)
                    {
                        foreach (var peer in reviewConfiguration.Peers)
                        {
                            newFeedback.Assessments.Add(new Assessment
                            {
                                ReviewCategory = reviewCategory,
                                Rating         = 7,
                                Reviewer       = reviewer,
                                ReviewedPeer   = peer
                            });
                        }
                    }
                    newFeedback.Reviewer = reviewer;
                    var reviewRound = new ReviewRound {
                        Active = true, StartDate = DateTime.UtcNow
                    };
                    reviewRound.Feedback.Add(newFeedback);
                    reviewConfiguration.ReviewRounds.Add(reviewRound);
                }
                ctx.SaveChanges();
                ScenarioContext.Current.Set(reviewConfiguration);
            }
        }
예제 #2
0
        public void SaveFeedback(string userEmail, FeedbackViewModel feedback)
        {
            var reviewFeedback =
                new ReviewFeedback
            {
                Reviewer = _databaseContext.UserProfiles.FirstOrDefault(user => user.EmailAddress == userEmail)
            };

            var reviewconfiguration = _databaseContext.ReviewConfigurations.Find(feedback.ReviewId);

            foreach (var categoriesWithPeersAndRating in feedback.CategoriesWithPeersAndRatings)
            {
                foreach (var peersWithRating in categoriesWithPeersAndRating.PeersWithRatings)
                {
                    reviewFeedback.Assessments.Add(
                        new Assessment
                    {
                        Rating         = peersWithRating.Rating,
                        Reviewer       = reviewFeedback.Reviewer,
                        ReviewCategory = _databaseContext.ReviewCategories.Find(categoriesWithPeersAndRating.Category.Id),
                        ReviewedPeer   = _databaseContext.UserProfiles.Find(peersWithRating.Peer.Id)
                    });
                }
            }

            reviewconfiguration.GetCurrentFeedback().Add(reviewFeedback);
            _databaseContext.SaveChanges();
        }