public JsonResult RefreshActivityIndex(int issueId, int userId, string right) { IssueCreating ic = new IssueCreating(); CreatingVM vm = new CreatingVM(); vm.UserWithMostChanges = ic.UserWithMostChanges(issueId); if (right == "O") { vm.AllUserChangeCounts = ic.GetAllChangeCountsByUser(issueId); vm.AllUserChangeCounts = ic.GetAllChangeCountsByUser(issueId); vm.GroupActivity = ic.GetGroupActivity(issueId); vm.GroupTrustworthiness = ic.GetGroupTrustworthiness(issueId); vm.DecisionTrustworthiness = ic.GetDecisionTrustworthiness(issueId); } else { vm.AllUserChangeCounts = new List <KeyValuePair <UserShortModel, int> >(); vm.AllUserChangeCounts = new List <KeyValuePair <UserShortModel, int> >(); vm.GroupActivity = new List <KeyValuePair <string, int> >(); vm.GroupTrustworthiness = new List <string>(); vm.DecisionTrustworthiness = new List <string>(); } vm.UserChangesCount = ic.GetUserChangesCount(issueId, userId); vm.InfoCount = ic.GetInfoCountForUser(issueId, userId); vm.LastChange = ic.GetLastChange(issueId); vm.Last100Changes = ic.GetLast100Changes(issueId); vm.UnreadInformation = ic.GetUnreadInformation(issueId, userId); var result = new JsonResult { Data = JsonConvert.SerializeObject(vm) }; return(result); }
public ActionResult Creating([FromJson] CreatingVM creatingVM) { IssueCreating ic = new IssueCreating(); int issueId = creatingVM.Issue.Id; int oldId = creatingVM.Issue.Id; int userId = GetUserIdFromClaim(); creatingVM.Issue.Id = ic.SaveIssue(creatingVM.Issue, userId, creatingVM.SelfAssessmentValue, creatingVM.SelfAssessmentDescription); issueId = creatingVM.Issue.Id; ic.UpdateIsseuTags(creatingVM.Issue.Id, creatingVM.AddedTags, creatingVM.DeletedTags, userId); ic.UpdateAccessRights(creatingVM.AddedAR, creatingVM.DeletedAR, creatingVM.AccessRights, issueId, userId); var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); if (oldId < 0) { context.Clients.All.userAddedToIssue(creatingVM.Issue, creatingVM.AccessRights, userId); } context.Clients.All.updateIssue(creatingVM.Issue, creatingVM.AddedTags, creatingVM.DeletedTags, ic.GetIssueTags(issueId), userId, creatingVM.SelfAssessmentValue, creatingVM.SelfAssessmentDescription); context.Clients.All.updateActivity(issueId, userId); return(RedirectToAction("Creating", "Issue", new { issueId = creatingVM.Issue.Id })); }
/// <summary> /// MVC get action for define issue view (Creating.cshtml) /// </summary> /// <param name="issueId">usually issue id of issue to be shown, but if issue id equals -1 then view for new issue is prepared</param> /// <returns>define issue vies (Creating.cshtml)</returns> public ActionResult Creating(int issueId) { CreatingVM vm = new CreatingVM(); IssueCreating ic = new IssueCreating(); int userId = GetUserIdFromClaim(); vm.AllTags = ic.GetAllTags(); vm.Issues = new List <IssueShort>(); vm.Issues.Add(new IssueShort(-1, "none")); vm.Issues.AddRange(ic.GetUserIssuesShort(userId)); vm.AllUsers = ic.GetAllUsers(); vm.UserId = userId; //existing issue if (issueId != -1) { vm.Issue = ic.GetIssue(issueId); vm.AccessRights = ic.GetAccessRightsOfIssue(issueId); AccessRightModel arm = ic.AccessRightOfUserForIssue(userId, issueId); vm.AccessRight = arm.Right; vm.SelfAssessmentDescription = arm.SelfAssessmentDescr; vm.SelfAssessmentValue = Convert.ToInt32(arm.SelfAssessmentValue); vm.Comments = ic.GetIssueComments(issueId, userId); vm.GroupthinkNotifications = ic.GetGroupthinkNotifications(issueId, userId); vm.GroupshiftProperties = ic.GetGropshiftProperties(issueId); if (ic.MarkAsRead(issueId, userId)) //try to makr issue as read for user { var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); ctx2.Clients.All.updateActivity(issueId, userId); } vm.UserWithMostChanges = ic.UserWithMostChanges(issueId); if (vm.AccessRight == "O") // specific inits for issue owner { vm.AllUserChangeCounts = ic.GetAllChangeCountsByUser(issueId); vm.GroupActivity = ic.GetGroupActivity(issueId); vm.GroupTrustworthiness = ic.GetGroupTrustworthiness(issueId); vm.DecisionTrustworthiness = ic.GetDecisionTrustworthiness(issueId); } else // inits for other users { vm.AllUserChangeCounts = new List <KeyValuePair <UserShortModel, int> >(); vm.GroupActivity = new List <KeyValuePair <string, int> >(); vm.GroupTrustworthiness = new List <string>(); vm.DecisionTrustworthiness = new List <string>(); } vm.UserChangesCount = ic.GetUserChangesCount(issueId, userId); vm.InfoCount = ic.GetInfoCountForUser(issueId, userId); vm.ReadInfoCount = ic.GetReadInfoCountForUser(issueId, userId); vm.UnreadInformation = ic.GetUnreadInformation(issueId, userId); vm.UserChanges = ic.GetUserChanges(issueId, userId); vm.LastChange = ic.GetLastChange(issueId); vm.Last100Changes = ic.GetLast100Changes(issueId); } else // new issue { vm.Issue = new IssueModel(); vm.Issue.Status = "CREATING"; vm.Issue.Setting = "A"; vm.Issue.AnonymousPosting = false; vm.AccessRights = new List <AccessRightModel>(); vm.AccessRights.Add(new AccessRightModel(userId, "Owner", vm.AllUsers.Where(x => x.Id == userId).FirstOrDefault().Name)); vm.AccessRight = "O"; vm.Issue.Id = -1; vm.Comments = new List <CommentModel>(); vm.GroupthinkNotifications = new List <NotificationModel>(); vm.GroupshiftProperties = new List <KeyValuePair <string, List <string> > >(); vm.InfoCount = 0; vm.ReadInfoCount = 0; vm.UserChangesCount = 0; vm.UserChanges = new List <UserChangeModel>(); vm.UnreadInformation = new List <KeyValuePair <string, int> >(); vm.Last100Changes = new List <UserChangeModel>(); vm.LastChange = new UserChangeModel(); vm.GroupActivity = new List <KeyValuePair <string, int> >(); vm.GroupTrustworthiness = new List <string>(); vm.DecisionTrustworthiness = new List <string>(); } vm.AllUsers = vm.AllUsers.Where(x => x.Id != userId).ToList(); UserShortModel rmUser; foreach (AccessRightModel arm in vm.AccessRights) { rmUser = vm.AllUsers.Where(x => x.Id == arm.UserId).FirstOrDefault(); vm.AllUsers.Remove(rmUser); } vm.AllUsers.Insert(0, new UserShortModel(0, "", "")); return(View(vm)); }