public virtual ActionResult Create(VotingCreateEditModel model) { if (model.IsPrivateToOrganization && string.IsNullOrEmpty(model.OrganizationId)) { ModelState.AddModelError("IsPrivateToOrganization", Resource.SelectOrganization); } if (!model.IsPrivateToOrganization && (model.Urls == null || !model.Urls.Any())) { ModelState.AddModelError("Urls", Resource.UrlIsRequired); } if (WorkContext.CategoryIds == null && (model.CategoryIds == null || !model.CategoryIds.Any())) { ModelState.AddModelError("CategoryIds", Globalization.Resources.Idea.Resource.CategoryIdsIsEmpty); } if (ModelState.IsValid) { var id = Service.Insert(model); if (!string.IsNullOrEmpty(id)) { TempData["Saved"] = true; return(RedirectToSuccessAction(model.IsPrivateToOrganization ? MVC.Organization.Details(model.OrganizationId, model.OrganizationName, OrganizationViews.Issues, null, null, null) : MVC.Voting.Details(id, model.Subject.ToSeoUrl()))); } } model = Service.FillCreateEditModel(model); return(View(MVC.Voting.Views._Create, model)); }
private void EnsureCanEdit(VotingCreateEditModel model) { if (!model.CanCurrentUserEdit) { var currentUserName = CurrentUser.FullName; throw new UnauthorizedAccessException(string.Format("UnauthorizedAccessException: You don't have access. You're currently logged in as {0}.", currentUserName)); } }
public virtual ActionResult Edit(VotingCreateEditModel model) { if (ModelState.IsValid) { Service.Edit(model); return(RedirectToAction(MVC.Voting.Details(model.Id, model.Subject.ToSeoUrl()))); } model = Service.FillCreateEditModel(model); return(View(MVC.Voting.Views._Create, model)); }