コード例 #1
0
        /// <summary>
        /// returns user ratings
        /// </summary>
        /// <param name="issueId"></param>
        /// <param name="userId"></param>
        /// <returns>array of lists of userRatings, one array stands for one alternative</returns>
        public List <RatingModel>[] GetIssueUserRatings(int issueId, int userId)
        {
            List <RatingModel>[] retArr;
            IssueBrCriteria      ibc = new IssueBrCriteria();
            int critCnt = ibc.GetIssueCriteria(issueId, userId).Count;

            retArr = new List <RatingModel> [critCnt];
            IssueBrAlternative iba = new IssueBrAlternative();
            int altcnt             = iba.GetIssueAlternatives(issueId, userId).Count;
            List <RatingModel> userRatings;
            RatingModel        rm = new RatingModel();

            userRatings = rm.ToModelList(RatingOp.GetUserRatings(issueId, userId), rm);

            int rowCnt = 0;
            int colCnt = 0;

            retArr[0] = new List <RatingModel>();
            foreach (RatingModel rat in userRatings)
            {
                if (colCnt == altcnt)
                {
                    colCnt = 0;
                    rowCnt++;
                    retArr[rowCnt] = new List <RatingModel>();
                }

                retArr[rowCnt].Add(rat);

                colCnt++;
            }

            return(retArr);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <param name="userId">user who is performing operation</param>
        /// <returns>alternative ratings/evaluations of all other users</returns>
        public List <RatingModel> GetAllIssueRatings(int issueId, int userId)
        {
            List <RatingModel> userRatings;
            RatingModel        rm = new RatingModel();

            userRatings = rm.ToModelList(RatingOp.GetAllIssueRatings(issueId, userId), rm);
            return(userRatings);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <summary>
        /// saves ratings
        /// </summary>
        /// <param name="ratings">array of lists where an list represents an alternative rating</param>
        public void SaveUserRatings(List <RatingModel>[] ratings)
        {
            List <RatingModel> ratList = new List <RatingModel>();

            for (int i = 0; i < ratings.Length; i++)
            {
                foreach (RatingModel rat in ratings[i])
                {
                    ratList.Add(rat);
                }
            }

            RatingModel   rm         = new RatingModel();
            List <Rating> entityList = rm.ToEntityList(ratList);

            RatingOp.SaveUserRatings(entityList);
        }
コード例 #5
0
        /// <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);
        }