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(); }
private void SendManuscript() { if (InputManuscriptTitle == "") { MessageBox.Show($"Please enter a title for the manuscript.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } else { var messageManuscriptTitle = InputManuscriptTitle; var la = new AuthorManuscriptSelectionViewDto() { AuthorId = LoggedAuthor.AuthorId, IsSelected = true, }; FrontAuthorList.Add(la); var selectedAuthors = FrontAuthorList.Where(c => c.IsSelected); foreach (var dto in selectedAuthors) { ManuscriptToAdd.AuthorsId.Add(dto.AuthorId); } FrontAuthorList.RemoveAt(FrontAuthorList.Count - 1); ManuscriptToAdd.ManuscriptTitle = InputManuscriptTitle; _addMultipleManuscriptService.AddMultipleManuscript(ManuscriptToAdd); InputManuscriptTitle = ""; MessageBox.Show($"Manuscript entitled as '{messageManuscriptTitle}' has been sent and will be reviewed by the editors and peer reviewers as soon as possible, stay tuned!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information); // Refresh DB _manuscriptService = new ListManuscriptService(_context); _notificationService = new ListNotificationService(_context); _authorManuscriptService = new ListAuthorManuscriptService(_context); var manuscripts = _manuscriptService.GetManuscriptList().ToList(); var notifications = _notificationService.GetNotificationList().ToList(); var authorManuscripts = _authorManuscriptService.GetAuthorManuscriptList().ToList(); ManuscriptList = new ObservableCollection <ManuscriptListDto>(manuscripts); NotificationList = new ObservableCollection <NotificationListDto>(notifications); AuthorManuscriptList = new ObservableCollection <AuthorManuscriptListDto>(authorManuscripts); //Refresh ListBox var latestManuscript = ManuscriptList.Last(); latestManuscript.ManuscriptTitle = LoggedManuscriptList.Count + 1 + ". " + latestManuscript.ManuscriptTitle; LoggedManuscriptList.Add(latestManuscript); } }
public AuthorViewModel(AuthorListDto loggedAuthor, AddMultipleManuscriptService addMultipleManuscriptService, ListFrontAuthorService listFrontAuthorService) : this(new EfCoreContext()) { InputManuscriptTitle = ""; LoggedAuthor = loggedAuthor; AuthorFirstName = loggedAuthor.Name.Split(' ').First() + "!"; _addMultipleManuscriptService = addMultipleManuscriptService; _listFrontAuthorService = listFrontAuthorService; ManuscriptToAdd = new AddMultipleManuscriptDto { ManuscriptTitle = "", }; _manuscriptService = new ListManuscriptService(_context); _notificationService = new ListNotificationService(_context); _authorManuscriptService = new ListAuthorManuscriptService(_context); var manuscripts = _manuscriptService.GetManuscriptList().ToList(); var notifications = _notificationService.GetNotificationList().ToList(); var authorManuscripts = _authorManuscriptService.GetAuthorManuscriptList().ToList(); ManuscriptList = new ObservableCollection <ManuscriptListDto>(manuscripts); NotificationList = new ObservableCollection <NotificationListDto>(notifications); AuthorManuscriptList = new ObservableCollection <AuthorManuscriptListDto>(authorManuscripts); var notificationCounter = 1; foreach (var notification in NotificationList) { if (loggedAuthor.AuthorId == notification.AuthorId) { notification.Message = notificationCounter + ". " + notification.Message; notificationCounter++; LoggedNotificationList.Add(notification); } } notificationCounter = 0; var manuscriptCounter = 1; var manuscriptIdBag = new List <int>(); foreach (var authorManuscript in AuthorManuscriptList) { if (authorManuscript.AuthorId == loggedAuthor.AuthorId) { manuscriptIdBag.Add(authorManuscript.ManuscriptId); } } foreach (var manuscript in manuscriptIdBag) { foreach (var parentManuscript in ManuscriptList) { if (manuscript == parentManuscript.ManuscriptId) { parentManuscript.ManuscriptTitle = manuscriptCounter + ". " + parentManuscript.ManuscriptTitle; manuscriptCounter++; LoggedManuscriptList.Add(parentManuscript); } } } manuscriptIdBag.Clear(); manuscriptCounter = 0; FrontAuthorList = GetAuthorSelectionList(); }