これは私のActionResultです
{
UsersModel um = new UsersModel();
um.Users = userRepository.GetAllUsers();
um.UserCustomers = userRepository.GetAllUserCustomerConnections();
um.UserTypes = enums.GetAllDescriptions(CodeType.UserType);
um.Customers = userRepository.GetAllCustomers();
um = SearchUsers(Request,um);
return View(um);
}
関数 SearchUsers を使用します。
private UsersModel SearchUsers(HttpRequestBase request, UsersModel curModel)
{
try
{
// request parameters
string userName = request.Params["user-name"];
string firstName = request.Params["first-name"];
string lastName = request.Params["last-name"];
int status,type,businessId;
if (!string.IsNullOrWhiteSpace(userName))
curModel.Users = curModel.Users.Where(u => u.Username.Contains(userName));
if (!string.IsNullOrWhiteSpace(firstName))
curModel.Users = curModel.Users.Where(u => u.FirstName.Contains(firstName));
if (!string.IsNullOrWhiteSpace(lastName))
curModel.Users = curModel.Users.Where(u => u.LastName.Contains(lastName));
if (int.TryParse(request.Params["status-search"], out status))
curModel.Users = curModel.Users.Where(u => u.Status == status);
if (int.TryParse(request.Params["userTypes-search"], out type))
curModel.Users = curModel.Users.Where(u => u.UserType == type);
if (int.TryParse(request.Params["busi-name"], out businessId))
curModel.Users = curModel.Users.Where(u => u.LastCustomerId == businessId);
return curModel;
}
catch
{
return curModel;
}
}
今、私は自分のビューに「search-users」というIDのボタンとjsファイルの私のコマンドを持っています:
$('#search-users').click(function () {
});
HttpRequestBase をコントローラーに投稿するにはどうすればよいですか?