public ActionResult Edit(FormCollection input) { var viewModel = new TagsAdminEditViewModel(); if ( !TryUpdateModel(viewModel) ) { return View(viewModel); } if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't edit tag"))) return new HttpUnauthorizedResult(); _tagService.UpdateTag(viewModel.Id, viewModel.TagName); return RedirectToAction("Index"); }
public ActionResult Edit(int id) { TagRecord tagRecord = _tagService.GetTag(id); if(tagRecord == null) { return RedirectToAction("Index"); } var viewModel = new TagsAdminEditViewModel { Id = tagRecord.Id, TagName = tagRecord.TagName, }; ViewData["ContentItems"] = _tagService.GetTaggedContentItems(id, VersionOptions.Latest).ToList(); return View(viewModel); }
public ActionResult Edit(FormCollection input) { var viewModel = new TagsAdminEditViewModel(); if ( !TryUpdateModel(viewModel) ) { return View(viewModel); } if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't edit tag"))) return new HttpUnauthorizedResult(); if (viewModel.TagName.Intersect(TagsPartDriver.DisalowedChars).Any()) { ModelState.AddModelError("_FORM", T("The tag \"{0}\" could not be modified because it contains forbidden chars: {1}", viewModel.TagName, String.Join(", ", TagsPartDriver.DisalowedChars))); return View(viewModel); } _tagService.UpdateTag(viewModel.Id, viewModel.TagName); return RedirectToAction("Index"); }
public ActionResult Edit(FormCollection input) { var viewModel = new TagsAdminEditViewModel(); try { UpdateModel(viewModel); if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't edit tag"))) return new HttpUnauthorizedResult(); _tagService.UpdateTag(viewModel.Id, viewModel.TagName); return RedirectToAction("Index"); } catch (Exception exception) { Services.Notifier.Error(T("Editing tag failed: " + exception.Message)); return View(viewModel); } }
public ActionResult Edit(int id) { try { Tag tag = _tagService.GetTag(id); var viewModel = new TagsAdminEditViewModel { Id = tag.Id, TagName = tag.TagName, }; return View(viewModel); } catch (Exception exception) { Services.Notifier.Error(T("Retrieving tag information failed: " + exception.Message)); return Index(); } }