Example #1
0
        public JsonResult RefreshUserIssue(int issueId, int userId)
        {
            IssueOverview  io     = new IssueOverview();
            UserIssueModel uim    = io.GetUserIssueModel(issueId, userId);
            var            result = new JsonResult
            {
                Data = JsonConvert.SerializeObject(uim)
            };

            return(result);
        }
Example #2
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);
        }