Ejemplo n.º 1
0
        public ActionResult CreateLawExpertComment(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.InitializeCreateExpertCommentModel(lawId);

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult LawDetails(int lawId)
        {
            LawService   service = new LawService();
            LawEditModel model   = service.GetLawEditModel(lawId);

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteLawCustomVote(int customVoteId)
        {
            LawService service   = new LawService();
            var        isDeleted = service.DeleteCustomVote(customVoteId);

            return(Json(new { isDeleted = isDeleted, customVoteId = customVoteId }, JsonRequestBehavior.AllowGet));;
        }
Ejemplo n.º 4
0
        public ActionResult LawDetails(int?lawId, string pCode, string scrollPosition, string sp)
        {
            if (lawId == null)
            {
                return(HttpNotFound());
            }

            LawService service = new LawService();
            LawModel   model   = service.GetLawModel(lawId.Value, User.Identity.GetUserId(), Infrastructure.CommentOrder.Chronological);

            if (model == null)
            {
                return(HttpNotFound());
            }

            new ParliamentService().GetTenantData(model.Law.ParliamentID, out string parliamentCode);
            if (pCode == null || pCode != parliamentCode)
            {
                return(RedirectToRoute(JavnaRasprava.Resources.Routes.JavnaRasprava_LawDetails, new { pCode = parliamentCode, lawId }));
            }

            QuestionsService questionsService = new QuestionsService();

            model.RepresentativeAnswers = questionsService.GetLatestAnswersForLaw(lawId.Value, User.Identity.GetUserId());

            ViewBag.scrollPosition = sp ?? scrollPosition;

            model.FbCommentsPath = string.Format(ConfigurationManager.AppSettings["Facebook.LawUrlTemplate"], lawId);

            return(View("Law", model));
        }
Ejemplo n.º 5
0
        public ActionResult EditLawSection(int lawSectionId)
        {
            LawService service = new LawService();
            var        model   = service.GetLawSectionEditModel(lawSectionId);

            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult DeleteLawSectionCustomVote(int lawSectionCustomVoteID)
        {
            LawService service   = new LawService();
            var        isDeleted = service.DeleteLawSectionCustomVote(lawSectionCustomVoteID);

            return(Json(new { isDeleted = isDeleted, lawSectionCustomVoteID = lawSectionCustomVoteID }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public ActionResult EditLawSectionCustomVote(int lawSectionCustomVoteID)
        {
            LawService service = new LawService();
            var        model   = service.GetLawSectionCustomVoteEditModel(lawSectionCustomVoteID);

            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult DeleteLawSection(int lawSectionId)
        {
            LawService service   = new LawService();
            var        isDeleted = service.DeleteLawSection(lawSectionId);

            return(Json(new { isDeleted = isDeleted, lawSectionId = lawSectionId }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
        public ActionResult ManageLawQuestions(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.GetLawEditModel(lawId);

            return(View(model));
        }
Ejemplo n.º 10
0
        public ActionResult CreateLaw()
        {
            LawService service = new LawService();
            var        model   = service.InitializeLawEditModel(SessionManager.Current.CurrentParliamentId);

            return(View(model));
        }
Ejemplo n.º 11
0
        public ActionResult CreateSuggestedRepresentative(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.InitializeCreateLawRepresentativeModel(lawId);

            return(View(model));
        }
Ejemplo n.º 12
0
        public ActionResult GetSectionVoteOptions(int lawId, int sectionId)
        {
            LawService service = new LawService();
            LawSectionCustomVoteListModel model = service.getLawSectionCustomVotesList(lawId, sectionId);

            return(PartialView("_SectionVoteOptions", model));
        }
Ejemplo n.º 13
0
        public void VoteLawsection_NewCustomVote_Voted()
        {
            var user = Helpers.CreateNewUser();
            var law  = Helpers.GetTestLaw();

            try
            {
                var lawModelOld        = new LawService().GetLawModel(law.LawID, user.Id, CommentOrder.Chronological);
                var lawSectionModelOld = lawModelOld.Sections.First();

                //new LawService().VoteLawSection( lawSectionModelOld.LawSection.LawSectionID, user.Id, -1, null );


                var lawModelNew        = new LawService().GetLawModel(law.LawID, user.Id, CommentOrder.Chronological);
                var lawSectionModelNew = lawModelNew.Sections.Where(x => x.LawSection.LawSectionID == lawSectionModelOld.LawSection.LawSectionID).First();


                Assert.AreEqual(lawSectionModelOld.VotesDown, lawSectionModelNew.VotesDown, "There Should be no changes in the vote");
                Assert.AreEqual(lawSectionModelOld.VotesUp, lawSectionModelNew.VotesDown, "There Should be no changes in the vote");
                Assert.AreEqual(true, lawSectionModelNew.UserVoted, "User did vote");
                Assert.AreEqual(false, lawSectionModelOld.UserVoted, "User did not have previous vote");
            }
            finally
            {
                Helpers.DeleteUser(user);
            }
        }
Ejemplo n.º 14
0
        public ActionResult GetLawVoteOptions(int lawId)
        {
            LawService             service = new LawService();
            LawCustomVoteListModel model   = service.GetLawCustomVotesList(lawId);

            return(PartialView("_LawVoteOptions", model));
        }
Ejemplo n.º 15
0
        public ActionResult ManageLawSuggestedRepresentatives(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.GetLawEditModel(lawId);

            return(View(model));
        }
Ejemplo n.º 16
0
        public void VoteLawSection_ExistingCustomVote_Voted()
        {
            var user = Helpers.CreateNewUser();
            var law  = Helpers.GetTestLaw();

            try
            {
                var lawModelOld        = new LawService().GetLawModel(law.LawID, user.Id, CommentOrder.Chronological);
                var lawSectionModelOld = lawModelOld.Sections.First();

                var customVotes = new LawService().getLawSectionCustomVotesList(lawSectionModelOld.LawSection.LawID, lawSectionModelOld.LawSection.LawSectionID);
                var customVote  = customVotes.LawSectionCustomVotes.Where(x => x.LawSectionCustomVoteID > 0).First();
                //new LawService().VoteLawSection( law.LawID, user.Id, customVote.LawSectionCustomVoteID, null );

                var lawModelNew        = new LawService().GetLawModel(law.LawID, user.Id, CommentOrder.Chronological);
                var lawSectionModelNew = lawModelNew.Sections.Where(x => x.LawSection.LawSectionID == lawSectionModelOld.LawSection.LawSectionID).First();

                int votesUpModifier   = customVote.Vote.Value ? 1 : 0;
                int votesDownModifier = customVote.Vote.Value ? 0 : 1;

                Assert.AreEqual(lawSectionModelOld.VotesDown + votesDownModifier, lawSectionModelNew.VotesDown, "Vote Down not counted");
                Assert.AreEqual(lawSectionModelOld.VotesUp + votesUpModifier, lawSectionModelNew.VotesUp, "Vote Down not counted");
                Assert.AreEqual(true, lawSectionModelNew.UserVoted, "User did vote");
                Assert.AreEqual(false, lawSectionModelOld.UserVoted, "User did not have previous vote");
            }
            finally
            {
                Helpers.DeleteUser(user);
            }
        }
Ejemplo n.º 17
0
        public ActionResult DeleteLawSuggestedRepresentative(int lawRepresentativeAssociationID)
        {
            LawService service   = new LawService();
            var        isDeleted = service.DeleteLawRepresentative(lawRepresentativeAssociationID);

            return(Json(new { isDeleted = isDeleted, lawRepresentativeAssociationID = lawRepresentativeAssociationID }, JsonRequestBehavior.AllowGet));;
        }
Ejemplo n.º 18
0
        public ActionResult IndexUnverifiedDirectQuestions()
        {
            LawService lawService = new LawService();
            var        model      = lawService.GetUnverifiedRepresentativeQuestions();

            return(PartialView("_IndexUnverifiedDirectQuestions", model));
        }
Ejemplo n.º 19
0
        public ActionResult Search()
        {
            LawService     service = new LawService();
            LawSearchModel model   = service.InitializeSearchModel();

            return(View(model));
        }
Ejemplo n.º 20
0
        public ActionResult IndexUnverifiedSectionAnswers()
        {
            LawService lawService = new LawService();
            var        model      = lawService.GetUnverifiedLawSectionCustomVotes();

            return(PartialView("_IndexUnverifiedSectionAnswers", model));
        }
Ejemplo n.º 21
0
        public ActionResult CreateLawSection(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.InitializeLawSectionEditModel(lawId);

            return(View(model));
        }
Ejemplo n.º 22
0
        public ActionResult DeleteLawQuestion(int questionId)
        {
            LawService service   = new LawService();
            var        isDeleted = service.DeletePredefinedQuestionEditModel(questionId);

            return(Json(new { isDeleted = isDeleted, questionId = questionId }, JsonRequestBehavior.AllowGet));;
        }
Ejemplo n.º 23
0
        public ActionResult EditLawQuestion(int questionId)
        {
            LawService service = new LawService();
            var        model   = service.GetPredefinedQuestionEditModel(questionId);

            return(View(model));
        }
Ejemplo n.º 24
0
        public ActionResult DeleteLaw(int lawId, string test)
        {
            LawService service = new LawService();

            service.DeleteLaw(lawId);
            return(RedirectToAction("ManageLaws"));
        }
Ejemplo n.º 25
0
        public ActionResult EditLawCustomVote(int customVoteId)
        {
            LawService service = new LawService();
            var        model   = service.GetCustomVoteEditModel(customVoteId);

            return(View(model));
        }
Ejemplo n.º 26
0
        public ActionResult CreateSuggestedRepresentative(CreateLawRepresentativeModel model)
        {
            TryUpdateModel(model);
            LawService service = new LawService();

            service.AddLawRepresentative(model);
            return(RedirectToAction("ManageLawSuggestedRepresentatives", new { lawId = model.LawID }));
        }
Ejemplo n.º 27
0
        public ActionResult CreateLawCustomVote(CustomVoteEditModel model)
        {
            TryUpdateModel(model);
            LawService service = new LawService();

            service.CreateCustomVote(model);
            return(RedirectToAction("ManageLawCustomVotes", new { lawId = model.LawID }));
        }
Ejemplo n.º 28
0
        public ActionResult CreateLawCustomVote(int lawId)
        {
            LawService service = new LawService();
            var        model   = service.InitializeCustomVoteEditModel(lawId);

            model.IsSuggested = true;
            return(View(model));
        }
Ejemplo n.º 29
0
        public ActionResult CreateLawExpertComment(CreateExpertcommentModel model)
        {
            TryUpdateModel(model);
            LawService service = new LawService();

            service.CreateExpertComment(model);
            return(RedirectToAction("ManageLawExpertComments", new { lawId = model.LawID }));
        }
Ejemplo n.º 30
0
        public ActionResult PointOutLawSectionRemove(int lawSectionId)
        {
            LawService service = new LawService();

            service.PointOutSection(lawSectionId, null);

            return(Json(new { isSuccess = true }, JsonRequestBehavior.AllowGet));
        }