/// <summary> /// retuns issueModel by issue id /// </summary> /// <param name="issueId"></param> /// <returns>IssueModel</returns> public IssueModel GetIssue(int issueId) { IssueModel im = new IssueModel(); im = im.ToModel(IssueOp.GetIssueById(issueId)); if (im.Parent != null) { int parrentIssueId = Convert.ToInt32(im.Parent); im.ParentTitle = IssueOp.GetIssueById(parrentIssueId).Title; } else { im.Parent = -1; } if (im.DependsOn != null) { int dependsOnIssueId = Convert.ToInt32(im.DependsOn); im.DependsOnTitle = IssueOp.GetIssueById(dependsOnIssueId).Title; } else { im.DependsOn = -1; } TagModel tm = new TagModel(); im.Tags = tm.ToModelList(TagOp.GetIssueTags(issueId), tm); return(im); }
private List <IssueModel> ChildIssues(List <IssueModel> list, int issueId) { List <IssueModel> children = new List <IssueModel>(); foreach (IssueModel model in list.Where(m => m.Parent == issueId)) { model.Children = ChildIssues(list, model.Id); TagModel tm = new TagModel(); model.Tags = tm.ToModelList(TagOp.GetIssueTags(model.Id), tm); children.Add(model); } if (children.Count == 0) { return(null); } else { return(children); } }
/// <summary> /// /// </summary> /// <param name="userId">user id</param> /// <returns>list of all issues which the user can access</returns> public List <IssueModel> GetUserIssues(int userId) { IssueModel im = new IssueModel(); List <IssueModel> allIssues = im.ToModelList(IssueOp.UserIssues(userId), im); List <IssueModel> rootIssues = new List <IssueModel>(); foreach (IssueModel model in allIssues.Where(m => m.Parent == null)) { TagModel tm = new TagModel(); model.Tags = tm.ToModelList(TagOp.GetIssueTags(model.Id), tm); model.Children = ChildIssues(allIssues, model.Id); rootIssues.Add(model); } List <IssueModel> hlist = new List <IssueModel>(); foreach (IssueModel m in rootIssues) { Traverse(m, m.Children, ref hlist); } return(hlist); }
/// <summary> /// returns list of issue tags /// </summary> /// <param name="issueId">issue id</param> /// <returns>List of issue tags</returns> public List <TagModel> GetIssueTags(int issueId) { TagModel tm = new TagModel(); return(tm.ToModelList(TagOp.GetIssueTags(issueId), tm)); }
/// <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); }