private void UpdateReview()
        {
            if (InputAppropriatenessScore == "" || InputClarityScore == "" || InputMethodologyScore == "" ||
                InputContributionScore == "" || InputRecommendationStatus == "")
            {
                MessageBox.Show($"Please fill in all ratings.",
                                "Error!",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                ReviewToUpdate.AppropriatenessScore = Convert.ToInt32(InputAppropriatenessScore);
                ReviewToUpdate.ClarityScore         = Convert.ToInt32(InputClarityScore);
                ReviewToUpdate.MethodologyScore     = Convert.ToInt32(InputMethodologyScore);
                ReviewToUpdate.ContributionScore    = Convert.ToInt32(InputContributionScore);
                ReviewToUpdate.RecommendationStatus = Convert.ToBoolean(Convert.ToInt32(InputRecommendationStatus));

                foreach (var manuscript in ManuscriptList)
                {
                    if (manuscript.ManuscriptId == SelectedManuscript.ManuscriptId)
                    {
                        foreach (var review in ReviewList)
                        {
                            if (review.ReviewerId == LoggedReviewer.ReviewerId && review.ManuscriptId == SelectedManuscript.ManuscriptId)
                            {
                                ReviewToUpdate.ReviewId = review.ReviewId;
                            }
                        }
                    }
                }
                _updateReviewService.UpdateReview(ReviewToUpdate);
                InputAppropriatenessScore = "";
                InputClarityScore         = "";
                InputMethodologyScore     = "";
                InputContributionScore    = "";
                InputRecommendationStatus = "";
                MessageBox.Show($"Manuscript entitled as '{SelectedManuscript.ManuscriptTitle}' has been reviewed, thank you for your service!",
                                "Success!",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);

                //Refresh DB
                _manuscriptService = new ListManuscriptService(_context);
                _reviewerService   = new ListReviewerService(_context);
                _reviewService     = new ListReviewService(_context);

                var manuscripts = _manuscriptService.GetManuscriptList().ToList();
                var reviewers   = _reviewerService.GetReviewerList().ToList();
                var reviews     = _reviewService.GetReviewList().ToList();

                ManuscriptList = new ObservableCollection <ManuscriptListDto>(manuscripts);
                ReviewerList   = new ObservableCollection <ReviewerListDto>(reviewers);
                ReviewList     = new ObservableCollection <ReviewListDto>(reviews);


                //Refresh ListBox
                LoggedManuscriptList.Remove(SelectedManuscript);
            }
        }
        public ReviewerViewModel(ReviewerListDto loggedReviewer, UpdateReviewService updateReviewService) : this(new EfCoreContext())
        {
            LoggedReviewer    = loggedReviewer;
            ReviewerFirstName = loggedReviewer.Name.Split(' ').First() + "!";

            InputAppropriatenessScore = "";
            InputClarityScore         = "";
            InputMethodologyScore     = "";
            InputContributionScore    = "";
            InputRecommendationStatus = "";

            _updateReviewService = updateReviewService;

            ReviewToUpdate = new ReviewListDto
            {
                AppropriatenessScore = 0,
                ClarityScore         = 0,
                MethodologyScore     = 0,
                ContributionScore    = 0,
                DateReviewed         = DateTime.Now,
            };

            _manuscriptService = new ListManuscriptService(_context);
            _reviewerService   = new ListReviewerService(_context);
            _reviewService     = new ListReviewService(_context);

            var manuscripts = _manuscriptService.GetManuscriptList().ToList();
            var reviewers   = _reviewerService.GetReviewerList().ToList();
            var reviews     = _reviewService.GetReviewList().ToList();

            ManuscriptList = new ObservableCollection <ManuscriptListDto>(manuscripts);
            ReviewerList   = new ObservableCollection <ReviewerListDto>(reviewers);
            ReviewList     = new ObservableCollection <ReviewListDto>(reviews);

            var manuscriptIdBag = new List <int>();

            foreach (var review in ReviewList)
            {
                if (review.ReviewerId == loggedReviewer.ReviewerId && review.AppropriatenessScore == 0)
                {
                    manuscriptIdBag.Add(review.ManuscriptId);
                }
            }

            foreach (var manuscript in manuscriptIdBag)
            {
                foreach (var parentManuscript in ManuscriptList)
                {
                    if (manuscript == parentManuscript.ManuscriptId)
                    {
                        LoggedManuscriptList.Add(parentManuscript);
                    }
                }
            }
            manuscriptIdBag.Clear();
        }
Esempio n. 3
0
        public PeopleViewModel() : this(new EfCoreContext())
        {
            _authorService   = new ListAuthorService(_context);
            _editorService   = new ListEditorService(_context);
            _reviewerService = new ListReviewerService(_context);

            var authors   = _authorService.GetAuthorList().ToList();
            var editors   = _editorService.GetEditorList().ToList();
            var reviewers = _reviewerService.GetReviewerList().ToList();

            AuthorList   = new ObservableCollection <AuthorListDto>(authors);
            EditorList   = new ObservableCollection <EditorListDto>(editors);
            ReviewerList = new ObservableCollection <ReviewerListDto>(reviewers);
        }
Esempio n. 4
0
        private void GoToCreateReviewerWindow()
        {
            _createReviewerWindow             = new CreateReviewerWindow();
            _createReviewerWindow.Owner       = Application.Current.MainWindow;
            _createReviewerWindow.DataContext = new AddReviewerViewModel(new AddReviewerService(_context), new ListAreaOfInterestService(_context));
            _createReviewerWindow.ShowDialog();
            //Refresh DB
            _authorService   = new ListAuthorService(_context);
            _editorService   = new ListEditorService(_context);
            _reviewerService = new ListReviewerService(_context);

            var authors   = _authorService.GetAuthorList().ToList();
            var editors   = _editorService.GetEditorList().ToList();
            var reviewers = _reviewerService.GetReviewerList().ToList();

            AuthorList   = new ObservableCollection <AuthorListDto>(authors);
            EditorList   = new ObservableCollection <EditorListDto>(editors);
            ReviewerList = new ObservableCollection <ReviewerListDto>(reviewers);
        }