Beispiel #1
0
        /// <summary>
        /// MVC get method for alternatives evaluation (Evaulation.cshtml)
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <returns>alternatives evaluation view (Evaulation.cshtml)</returns>
        public ActionResult Evaluation(int issueId)
        {
            IssueCreating   ic     = new IssueCreating();
            EvaluationVM    evm    = new EvaluationVM();
            IssueEvaluation ie     = new IssueEvaluation();
            int             userId = GetUserIdFromClaim();

            evm.Issue = ic.GetIssue(issueId);
            if (evm.Issue.Status == "CREATING" || evm.Issue.Status == "BRAINSTORMING1" || evm.Issue.Status == "BRAINSTORMING2")
            {
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }
            //ToDo check viewsettings & issueOwner
            evm.AllRatings   = ie.GetAllIssueRatings(issueId, userId);
            evm.UserRatings  = ie.GetIssueUserRatings(issueId, userId);
            evm.Criterias    = ie.GetIssueCrtieria(issueId, userId);
            evm.Alternatives = ie.GetIssueAlternatives(issueId, userId);
            evm.RatedUsers   = ie.GetRatedUsersForIssue(issueId, userId);
            evm.RatedUserCnt = evm.RatedUsers.Count;
            evm.AccessRight  = ic.AccessRightOfUserForIssue(userId, issueId).Right;
            evm.UserId       = userId;

            if (evm.Issue.Setting == "B")
            {
                IssueCriterionWeight icw = new IssueCriterionWeight();
                evm.SliderValues    = ie.GetSliderValues();
                evm.PairwiseRatings = ie.GetPairwiseAlternativeRatings(issueId, userId);
            }

            return(View(evm));
        }
Beispiel #2
0
        /// <summary>
        /// MVC get method for criteria weighting view (CriteriaRating.cshtml)
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <returns>criteria weighting view (CriteraRating.cshtml)</returns>
        public ActionResult CriteriaRating(int issueId)
        {
            CriteriaWeightsVM    vm  = new CriteriaWeightsVM();
            IssueCreating        ic  = new IssueCreating();
            IssueCriterionWeight icw = new IssueCriterionWeight();
            int userId = GetUserIdFromClaim();

            vm.Issue = ic.GetIssue(issueId);
            if (vm.Issue.Status == "CREATING" || vm.Issue.Status == "BRAINSTORMING1")
            {
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }
            vm.AccessRight = ic.AccessRightOfUserForIssue(userId, issueId).Right;
            vm.UserId      = userId;

            if (vm.Issue.Setting == "B")
            {
                vm.PCCriteria   = icw.GetPCCriteria(issueId, userId);
                vm.SliderValues = icw.GetSliderValues();
            }

            vm.UserWeights  = icw.GetUserWeights(issueId, userId);
            vm.OtherWeights = icw.GetIssueWeights(issueId, userId);
            vm.VotedUsers   = new List <UserWithCW>();
            int i = 0;

            foreach (List <CriterionWeightModel> cwmL in vm.OtherWeights)
            {
                vm.VotedUsers.Add(new UserWithCW(cwmL.FirstOrDefault().UserId, cwmL.FirstOrDefault().Name));
                vm.VotedUsers[i].UserCriterionWeights = vm.OtherWeights[i];
                i++;
            }

            return(View(vm));
        }
Beispiel #3
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));
        }
Beispiel #4
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));
        }
Beispiel #5
0
        public ActionResult BrCriteria(int issueId)
        {
            IssueCreating ic        = new IssueCreating();
            BrCriteriaVM  viewModel = new BrCriteriaVM();
            int           userId    = GetUserIdFromClaim();

            viewModel.Issue = ic.GetIssue(issueId);
            if (viewModel.Issue.Status == "CREATING")
            {
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }
            IssueBrCriteria ibc = new IssueBrCriteria();

            viewModel.IssueCriteria = ibc.GetIssueCriteria(issueId, userId);
            viewModel.AccessRight   = ic.AccessRightOfUserForIssue(userId, issueId).Right;
            viewModel.UserId        = userId;
            if (ibc.MarkAsRead(issueId, userId))
            {
                var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
                ctx2.Clients.All.updateActivity(issueId, userId);
            }
            return(View(viewModel));
        }
Beispiel #6
0
        /// <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));
        }