public ActionResult Create(RedirectModel model) { if (ModelState.IsValid) { _redirectRepository.Create(new Redirect { IsPermanent = !model.Temporary, OldRoute = model.From.TrimStart('/'), NewRoute = "/" + model.To.TrimStart('/') }); return Json(new { success = true }); } return PartialView("CreateModal", model); }
public ActionResult Delete(int id, RedirectModel model) { var redirect = _redirectRepository.GetBy(r => r.Id == id); if (redirect == null) { throw new HttpException((int)HttpStatusCode.NotFound, "The specified redirect was not found"); } if (ModelState.IsValid) { _redirectRepository.Delete(redirect); return Json(new { success = true }); } return PartialView("DeleteModal", new RedirectModel { Id = redirect.Id, From = redirect.OldRoute, To = redirect.NewRoute, Temporary = !redirect.IsPermanent }); }