protected RedirectToRouteResult RedirectToNotFound(BaseController controller) { RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary()); controller.When(sub => sub.RedirectToNotFound()).DoNotCallBase(); controller.RedirectToNotFound().Returns(result); return result; }
protected RedirectToRouteResult NotEmptyView(BaseController controller, Object model) { RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary()); controller.When(sub => sub.NotEmptyView(model)).DoNotCallBase(); controller.NotEmptyView(model).Returns(result); return result; }
protected RedirectToRouteResult RedirectIfAuthorized(BaseController controller, String actionName, String controllerName) { RedirectToRouteResult result = new RedirectToRouteResult(new RouteValueDictionary()); controller.When(sub => sub.RedirectIfAuthorized(actionName, controllerName)).DoNotCallBase(); controller.RedirectIfAuthorized(actionName, controllerName).Returns(result); return result; }
/// <summary> /// Returns a ViewResult with content type set as xml /// </summary> public static ActionResult XmlViewResult(BaseController controller, object model, string viewName = null) { controller.ControllerContext.HttpContext.Response.ContentType = "text/xml; charset=UTF-8"; if (model != null) { controller.ViewData.Model = model; } ViewResult result = new ViewResult(); result.ViewName = viewName; result.ViewData = controller.ViewData; result.TempData = controller.TempData; return result; }
/// <summary> /// Returns a status 404 to the client and the error 404 view. /// </summary> /// <param name="emptyBody">true: the response ends</param> public static ActionResult NotFoundResult(BaseController controller, bool emptyBody) { controller.ControllerContext.HttpContext.Response.StatusCode = 404; if (emptyBody) { controller.ControllerContext.HttpContext.Response.End(); } ViewResult viewResult = new ViewResult(); viewResult.ViewName = "Errors/404"; viewResult.MasterName = controller.GetDefaultMasterName(); return viewResult; }
protected void ReturnCurrentAccountId(BaseController controller, String id) { controller.When(sub => { String get = sub.CurrentAccountId; }).DoNotCallBase(); controller.CurrentAccountId.Returns(id); }
/// <summary> /// Returns a status 404 to the client and the error 404 view. /// </summary> /// <param name="controller"></param> /// <returns></returns> public static ActionResult NotFoundResult(BaseController controller) { return NotFoundResult(controller, false); }
public static ActionResult MovedPermanentlyResult(BaseController controller, object routeValues) { return new NearForums.Web.Extensions.MovedPermanentlyResult(routeValues); }
/// <summary> /// Returns a http status 403 to the client and the error 403 view. /// </summary> /// <param name="controller"></param> /// <returns></returns> public static ActionResult ForbiddenResult(BaseController controller) { return ForbiddenResult(controller, false); }