/// <summary> /// /// </summary> /// <param name="issueId">issue id</param> /// <param name="userId">user id who is performing operation</param> /// <returns>array of lists containging user criteria weights</returns> public List <CriterionWeightModel>[] GetIssueWeights(int issueId, int userId) { CriterionWeightModel cwm = new CriterionWeightModel(); List <CriterionWeightModel> allWeightsList = cwm.ToModelList(CriterionWeightOp.GetIssueWeights(issueId, userId), cwm); //allWeightsList = allWeightsList.Where(x => x.UserId != userId).ToList() ; IssueCreating ic = new IssueCreating(); List <UserShortModel> allUsers = ic.GetAllUsers(); List <int> distinctUsers = allWeightsList.GroupBy(x => x.UserId).Select(grp => grp.First()).Select(x => x.UserId).ToList(); List <CriterionWeightModel>[] arrayList = new List <CriterionWeightModel> [distinctUsers.Count]; int cnt = 0; foreach (int uId in distinctUsers) { arrayList[cnt] = new List <CriterionWeightModel>(); string name = allUsers.Where(x => x.Id == uId).FirstOrDefault().Name; foreach (CriterionWeightModel model in allWeightsList.Where(x => x.UserId == uId).OrderBy(x => x.CriterionId)) { model.Name = name; arrayList[cnt].Add(model); } cnt++; } return(arrayList); }
/// <summary> /// returns list of users who have already rated /// </summary> /// <param name="issueId">issue id</param> /// <param name="userId">user id who is performing operation</param> /// <returns>list of users</returns> public List <UserShortModel> GetRatedUsersForIssue(int issueId, int userId) { List <int> userIds = RatingOp.GetAlreadyRatedUsers(issueId, userId); IssueCreating ic = new IssueCreating(); List <UserShortModel> allUsers = ic.GetAllUsers(); List <UserShortModel> ratedUsers = new List <UserShortModel>(); foreach (int id in userIds) { ratedUsers.Add(allUsers.Where(x => x.Id == id).FirstOrDefault()); } return(ratedUsers); }
/// <summary> /// converts inssue model to user issue model /// </summary> /// <param name="im">issue model</param> /// <param name="userId">user who is performing operation</param> /// <returns>user issue model</returns> private UserIssueModel GetUserIssueModelFromIssueModel(IssueModel im, int userId) { UserIssueModel uim = new UserIssueModel(); int unreadCnt; List <KeyValuePair <string, int> > unreadInfos; uim.Issue = im; uim.SelfAssessmentActionRequired = AccessRightOp.SelfAssessmentActionRequired(im.Id, userId); uim.CriteriaActionRatingRequired = CriterionOp.CriteriaWeightingActionRequired(im.Id, userId); uim.EvaluationActionRequired = RatingOp.GetRatingActionRequired(im.Id, userId); uim.UnreadCoreItems = new List <string>(); unreadInfos = InformationReadOp.GetUnreadInfos(im.Id, userId); unreadCnt = 0; foreach (KeyValuePair <string, int> kvp in unreadInfos) { if (kvp.Key.StartsWith("Alternative I") || kvp.Key.StartsWith("Issue I") || kvp.Key.StartsWith("Criteria I")) { unreadCnt = unreadCnt + kvp.Value; if (kvp.Value > 0) { if (kvp.Key.StartsWith("Alternative Information")) { uim.UnreadCoreItems.Add(kvp.Value + " new Alternatives"); } if (kvp.Key.StartsWith("Issue Information")) { uim.UnreadCoreItems.Add(kvp.Value + " new Issue Attributes"); } if (kvp.Key.StartsWith("Criteria Information")) { uim.UnreadCoreItems.Add(kvp.Value + " new Criteria"); } } } } uim.UnreadCoreItemsCount = unreadCnt; TagModel tm = new TagModel(); if (uim.Issue.Tags == null || uim.Issue.Tags.Count == 0) { uim.Issue.Tags = tm.ToModelList(TagOp.GetIssueTags(uim.Issue.Id), tm); } ReviewModel rm = new ReviewModel(); IssueCreating ic = new IssueCreating(); List <UserShortModel> userList = ic.GetAllUsers(); UserShortModel usm; if (uim.Issue.Status == "FINISHED" || uim.Issue.Status == "CLOSED") { uim.Rating = ReviewOp.GetReviewRating(uim.Issue.Id); uim.Reviews = rm.ToModelList(ReviewOp.GetIssueReviews(uim.Issue.Id), rm); foreach (ReviewModel reviewModel in uim.Reviews) { usm = userList.Find(x => x.Id == reviewModel.UserId); reviewModel.UserName = usm.FirstName + " " + usm.LastName; } } else { uim.Rating = 0.0; } return(uim); }