You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
using System;
|
|
using System.Linq.Expressions;
|
|
using Infrastructure.Application;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace Infrastructure.Web
|
|
{
|
|
public class BaseController : Controller
|
|
{
|
|
public IActionResult RedirectTo(string action = "Index", string controller = null, string message = "操作成功,正在为您跳转", object routeValues = null, string returnUrl = null)
|
|
{
|
|
ViewBag.Message = message;
|
|
ViewBag.Url = string.IsNullOrEmpty(returnUrl) ? Url.Action("Index", controller, routeValues) : returnUrl;
|
|
return View("Redirect");
|
|
}
|
|
|
|
public void SelectList<TResult>(Expression<Func<object, TResult>> expression, Func<MultiSelectList> selectListFunc, bool value = true)
|
|
{
|
|
if (value)
|
|
{
|
|
var name = (expression.Body as MemberExpression).Member.Name;
|
|
SelectList(name, selectListFunc, true);
|
|
}
|
|
}
|
|
|
|
public void SelectList(string name, Func<MultiSelectList> selectListFunc, bool value = true)
|
|
{
|
|
if (value)
|
|
{
|
|
ViewData[name] = selectListFunc();
|
|
}
|
|
}
|
|
}
|
|
} |