Esempio n. 1
0
        public ActionResult EditPetition(_EditPetitionViewModel model)
        {
            if (!Request.IsAuthenticated)
                throw new AuthenticationException();

            if (ModelState.IsValid)
            {
                PetitionContainer data = new PetitionContainer
                {
                    GroupId = model.GroupId,
                    Id = model.Id,
                    IsPrivate = model.IsPrivate,
                    Tags = model.TagTitles,
                    Text = model.Text,
                    Title = model.Title
                };

                Petition petition = VotingService.EditPetition(data, UserContext.Current.Id);

                return RedirectToAction("petition", petition.Controller, new { id = petition.Id });
            }

            if (model.GroupId != null)
                View("../group/editpetition", model);

            return View("../user/editpetition", model);
        }
Esempio n. 2
0
        public GroupEditPetitionViewModel(Petition petition)
        {
            if (petition != null)
            {
                if (petition.GroupId.HasValue)
                {
                    GroupId             = petition.GroupId.Value;
                    GroupName           = petition.Group.Name;
                    GroupUrl            = petition.Group.Url;
                    IsContentModeration = petition.Group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);
                }

                EditPetition = new _EditPetitionViewModel(petition);
            }
        }
        public GroupEditPetitionViewModel(Petition petition)
        {
            if (petition != null)
            {
                if (petition.GroupId.HasValue)
                {
                    GroupId = petition.GroupId.Value;
                    GroupName = petition.Group.Name;
                    GroupUrl = petition.Group.Url;
                    IsContentModeration = petition.Group.PrivacyEnum.HasFlag(GroupPrivacy.ContentModeration);
                }

                EditPetition = new _EditPetitionViewModel(petition);
            }
        }