Esempio n. 1
0
        /// <summary>
        /// MVC get method for decide view (Decision.cshtml)
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <returns>decide view (Decision.cshtml)</returns>
        public ActionResult Decision(int issueId)
        {
            DecisionVM         dvm = new DecisionVM();
            IssueCreating      ic  = new IssueCreating();
            IssueBrAlternative iba = new IssueBrAlternative();
            IssueDecision      id  = new IssueDecision();
            int userId             = GetUserIdFromClaim();

            dvm.AccessRight  = ic.AccessRightOfUserForIssue(userId, issueId).Right;
            dvm.Alternatives = iba.GetIssueAlternatives(issueId, userId).OrderByDescending(x => x.Rating).ToList();
            dvm.Issue        = ic.GetIssue(issueId);

            if (dvm.Issue.Status == "CREATING" || dvm.Issue.Status == "BRAINSTORMING1" || dvm.Issue.Status == "BRAINSTORMING2" || dvm.Issue.Status == "EVALUATING")
            {
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }

            dvm.OldDecisions = id.GetOldDecisions(issueId, userId);
            dvm.Decision     = id.GetDecision(issueId, userId);
            dvm.UserId       = GetUserIdFromClaim();
            return(View(dvm));
        }
Esempio n. 2
0
        public ActionResult BrAlternatives([FromJson] BrAlternativesVM brAlternativesVM)
        {
            IssueBrAlternative iba = new IssueBrAlternative();
            int userId             = GetUserIdFromClaim();

            iba.UpdateAlternatives(brAlternativesVM.Alternatives, brAlternativesVM.DeletedAlternatives, userId);
            brAlternativesVM.Alternatives = iba.GetIssueAlternatives(brAlternativesVM.Issue.Id, userId);

            UserShortModel user    = new UserShortModel(brAlternativesVM.UserId, GetUserNameFromClaim());
            var            context = GlobalHost.ConnectionManager.GetHubContext <AlternativeHub>();

            context.Clients.All.updateAlternatives(brAlternativesVM.Alternatives, user, brAlternativesVM.Issue.Id);
            if (brAlternativesVM.DeletedAlternatives != null && brAlternativesVM.DeletedAlternatives.Count > 0)
            {
                context.Clients.All.deleteAlternatives(brAlternativesVM.DeletedAlternatives, user);
            }

            brAlternativesVM.DeletedAlternatives = new List <int>();
            var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            ctx2.Clients.All.updateActivity(brAlternativesVM.Issue.Id, brAlternativesVM.UserId);
            return(View(brAlternativesVM));
        }
Esempio n. 3
0
        public ActionResult BrAlternatives(int issueId)
        {
            BrAlternativesVM vm = new BrAlternativesVM();
            IssueCreating    ic = new IssueCreating();
            int userId          = GetUserIdFromClaim();

            vm.Issue = ic.GetIssue(issueId);
            if (vm.Issue.Status == "CREATING")
            {
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }
            IssueBrAlternative iba = new IssueBrAlternative();

            vm.Alternatives = iba.GetIssueAlternatives(issueId, userId);
            vm.AccessRight  = ic.AccessRightOfUserForIssue(userId, issueId).Right;
            vm.UserId       = userId;
            if (iba.MarkAsRead(issueId, userId))
            {
                var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
                ctx2.Clients.All.updateActivity(issueId, userId);
            }
            return(View(vm));
        }