private void EnsureIsCreator(IdeaCreateEditModel 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(IdeaCreateEditModel model) { if (ModelState.IsValid) { var publish = Service.Edit(model); if (publish) { TempData["Saved"] = true; } return(RedirectToAction(MVC.Idea.Details(model.Id, model.Subject.ToSeoUrl(), null))); } model = Service.FillCreateEditModel(model); return(View(MVC.Idea.Views._Create, model)); }
public virtual ActionResult Create(IdeaCreateEditModel model) { if (model.IsPrivateToOrganization && string.IsNullOrEmpty(model.OrganizationId)) { ModelState.AddModelError("IsPrivateToOrganization", Resource.SelectOrganization); } if (WorkContext.CategoryIds == null && (model.CategoryIds == null || !model.CategoryIds.Any())) { ModelState.AddModelError("CategoryIds", Resource.CategoryIdsIsEmpty); } //EnsureIsUnique(); if (ModelState.IsValid) { var id = Service.Insert(model); if (!string.IsNullOrEmpty(id)) { if (!model.IsDraft) { TempData["Saved"] = true; } return (RedirectToSuccessAction(model.IsPrivateToOrganization ? MVC.Organization.Details(model.OrganizationId, model.OrganizationName, OrganizationViews.Ideas, null, null, null) : MVC.Idea.Details(id, model.Subject.ToSeoUrl(), null))); } } model = Service.FillCreateEditModel(model); return(View(MVC.Idea.Views._Create, model)); }
public virtual ActionResult SaveTempModel(IdeaCreateEditModel model) { TempModel = Service.FillCreateEditModel(model); return(Json(true)); }