Beispiel #1
0
        public ActionResult DeleteIssue(int issueId)
        {
            IssueCreating ic = new IssueCreating();

            ic.DeleteIssue(issueId);
            return(RedirectToAction("Index", "Issue"));
        }
Beispiel #2
0
        public HttpResponseMessage MarkNotificationAsRead(int notificationId)
        {
            IssueCreating ic = new IssueCreating();

            ic.MarkNotificationAsRead(notificationId);
            return(new HttpResponseMessage());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
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 #5
0
        /// <summary>
        /// MVC post method for update decision
        /// </summary>
        /// <param name="dmvm">Decision view model with regarding information</param>
        /// <returns>updated decision view</returns>
        public ActionResult UpdateDecision(DecisionModelVM dmvm)
        {
            IssueDecision id            = new IssueDecision();
            DecisionModel decisionModel = new DecisionModel();

            decisionModel.AlternativeId = dmvm.AlternativeId;
            decisionModel.ChangeDate    = dmvm.ChangeDate;
            decisionModel.Explanation   = dmvm.Explanation;
            decisionModel.IssueId       = dmvm.IssueId;
            id.UpdateDecision(decisionModel, GetUserIdFromClaim());

            int           issueId = decisionModel.IssueId;
            int           userId  = GetUserIdFromClaim();
            DecisionVM    dvm     = new DecisionVM();
            IssueCreating ic      = new IssueCreating();

            dvm.OldDecisions = id.GetOldDecisions(issueId, userId);
            dvm.Decision     = id.GetDecision(issueId, userId);
            dvm.Issue        = ic.GetIssue(issueId);
            var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            ctx2.Clients.All.decisionUpdated(dvm, issueId);

            return(RedirectToAction("Decision", "Issue", new { issueId = decisionModel.IssueId }));
        }
Beispiel #6
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 #7
0
        public HttpResponseMessage AddComment(CommentModel commentModel)
        {
            IssueCreating ic = new IssueCreating();

            ic.AddCommentToAlternative(commentModel, GetUserIdFromClaim());

            commentModel.UserId = GetUserIdFromClaim();
            if (commentModel.Anonymous)
            {
                commentModel.Name = "Anonymous";
            }
            else
            {
                commentModel.Name = GetUserNameFromClaim();
            }
            var context = GlobalHost.ConnectionManager.GetHubContext <CommentHub>();

            context.Clients.All.addNewComment(commentModel);

            var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            ctx2.Clients.All.updateActivity(commentModel.IssueId, commentModel.UserId);

            return(new HttpResponseMessage());
        }
Beispiel #8
0
        public JsonResult GetGroupshiftProperties(int issueId)
        {
            IssueCreating ic     = new IssueCreating();
            var           result = new JsonResult
            {
                Data = JsonConvert.SerializeObject(ic.GetGropshiftProperties(issueId))
            };

            return(result);
        }
Beispiel #9
0
        public JsonResult SelfAssessmentRefreshed(int issueId, int userId)
        {
            IssueCreating ic     = new IssueCreating();
            var           result = new JsonResult
            {
                Data = JsonConvert.SerializeObject(ic.GetAccessRight(issueId, userId))
            };

            return(result);
        }
Beispiel #10
0
        public HttpResponseMessage AddNotification(NotificationModel notificationModel)
        {
            IssueCreating ic = new IssueCreating();

            notificationModel.UserId = GetUserIdFromClaim();
            notificationModel.Id     = ic.SendNotification(notificationModel);

            var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            context.Clients.All.sendNotification(notificationModel);

            return(new HttpResponseMessage());
        }
Beispiel #11
0
        public ActionResult NextStage(int issueId, string status)
        {
            IssueCreating ic = new IssueCreating();

            ic.NextStage(issueId, GetUserIdFromClaim());
            string st      = status.Remove(status.Length - 1, 1).Remove(0, 1);
            var    context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
            int    userId  = GetUserIdFromClaim();

            if (st == "CREATING")
            {
                context.Clients.All.nextStage(issueId, "BRAINSTORMING1", userId);
                return(RedirectToAction("BrCriteria", "Issue", new { issueId = issueId }));
            }
            else if (st == "BRAINSTORMING1")
            {
                context.Clients.All.nextStage(issueId, "BRAINSTORMING2", userId);
                return(RedirectToAction("CriteriaRating", "Issue", new { issueId = issueId }));
            }
            else if (st == "BRAINSTORMING2")
            {
                context.Clients.All.nextStage(issueId, "EVALUATING", userId);
                return(RedirectToAction("EVALUATION", "Issue", new { issueId = issueId }));
            }
            else if (st == "EVALUATING")
            {
                context.Clients.All.nextStage(issueId, "DECIDING", userId);
                return(RedirectToAction("Decision", "Issue", new { issueId = issueId }));
            }
            else if (st == "DECIDING")
            {
                context.Clients.All.nextStage(issueId, "FINISHED", userId);
                return(RedirectToAction("Index", "Issue"));
            }
            else if (st == "FINISHED")
            {
                context.Clients.All.nextStage(issueId, "CLOSED", userId);
                return(RedirectToAction("Index", "Issue"));
            }
            else
            {
                context.Clients.All.nextStage(issueId, "FINISHED", userId);
                return(RedirectToAction("Creating", "Issue", new { issueId = issueId }));
            }
        }
Beispiel #12
0
        public HttpResponseMessage RemoveAccessRight(AccessRightModel accessRight)
        {
            HttpResponseMessage msg = new HttpResponseMessage();
            IssueCreating       ic  = new IssueCreating();

            if (ic.RemoveAccessRight(accessRight, GetUserIdFromClaim()))
            {
                msg.StatusCode = System.Net.HttpStatusCode.OK;

                var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
                context.Clients.All.userRemovedFromIssue(accessRight.IssueId, accessRight.UserId, GetUserIdFromClaim());
            }
            else
            {
                msg.StatusCode = System.Net.HttpStatusCode.InternalServerError;
            }
            return(msg);
        }
Beispiel #13
0
        /// <summary>
        /// http post method for marking comments as read
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <param name="type">string and possible options are: Issue, Alternative, Criterion</param>
        /// <returns>Http response message</returns>
        public HttpResponseMessage MarkCommentsAsRead(int issueId, string type)
        {
            HttpResponseMessage msg = new HttpResponseMessage();
            int userId = GetUserIdFromClaim();

            if (type == "Issue")
            {
                IssueCreating ic = new IssueCreating();
                ic.MarkCommentsAsRead(issueId, userId);
            }
            else if (type == "Alternative")
            {
                IssueBrAlternative iba = new IssueBrAlternative();
                iba.MarkCommentsAsRead(issueId, userId);
            }
            else if (type == "Criterion")
            {
                IssueBrCriteria ibc = new IssueBrCriteria();
                ibc.MarkCommentsAsRead(issueId, userId);
            }
            return(msg);
        }
Beispiel #14
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 #15
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 #16
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 #17
0
        public HttpResponseMessage MarkCommentAsRead(int issueId, string type)
        {
            HttpResponseMessage msg = new HttpResponseMessage();

            if (type == "Criterion")
            {
                IssueBrCriteria ibc = new IssueBrCriteria();
                ibc.MarkCommentsAsRead(issueId, GetUserIdFromClaim());
            }
            else if (type == "Alternative")
            {
                IssueBrAlternative iba = new IssueBrAlternative();
                iba.MarkCommentsAsRead(issueId, GetUserIdFromClaim());
            }
            else if (type == "Issue")
            {
                IssueCreating ic = new IssueCreating();
                ic.MarkCommentsAsRead(issueId, GetUserIdFromClaim());
            }

            msg.StatusCode = System.Net.HttpStatusCode.OK;
            return(msg);
        }
Beispiel #18
0
        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 }));
        }
Beispiel #19
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));
        }