Exemple #1
0
        public ActionResult EditPetition(PetitionModel model)
        {
            TryUpdateModel(model);
            PetitionService service = new PetitionService();

            service.UpdatePetition(model, User.Identity.GetUserId());
            return(RedirectToAction("PetitionDetails", new { petitionId = model.PetitionID }));
        }
Exemple #2
0
        public void UpdatePetition_New_Updated()
        {
            var user = Helpers.CreateNewUser();

            Models.PetitionModel model      = null;
            Models.PetitionModel savedModel = null;
            int petitionID = 0;

            try
            {
                var service = new PetitionService();
                model = new Models.PetitionModel
                {
                    Title             = "Some Title",
                    Description       = "Some Description",
                    SubmitterName     = "Some user",
                    SubmitterUserID   = user.Id,
                    TargetInstitution = "Test institution",
                    Verified          = false
                };

                petitionID = service.CreateNewPetition(model);
                Assert.AreNotEqual(0, petitionID, "ID not created");

                savedModel = service.GetPetition(petitionID, user.Id);
                Assert.IsNotNull(savedModel);

                string newTitle = "Some new title";
                savedModel.Title = newTitle;
                var changedModel = service.UpdatePetition(savedModel, user.Id);

                Assert.IsNotNull(savedModel);
                Assert.AreEqual(newTitle, changedModel.Title, "Title Changed");
                Assert.AreEqual(changedModel.Description, model.Description, "Description did not change");
            }
            finally
            {
                Helpers.DeleteUser(user);

                if (model != null)
                {
                    new PetitionService().DeletePetition(petitionID);
                }
            }
        }