本文整理汇总了C#中UserViewModel.InjectFrom方法的典型用法代码示例。如果您正苦于以下问题:C# UserViewModel.InjectFrom方法的具体用法?C# UserViewModel.InjectFrom怎么用?C# UserViewModel.InjectFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserViewModel
的用法示例。
在下文中一共展示了UserViewModel.InjectFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Edit
public ActionResult Edit(string username)
{
if ( username == _currentUser.Username )
{
var editUser = new UserViewModel();
editUser.InjectFrom(_currentUser);
return View(editUser);
}
if ( _currentUser.HasRole("Manager"))
{
var user = _authManager.GetUser(username);
if ( user == null )
{
return HttpNotFound("User Not Found");
}
var editUser = new UserViewModel();
editUser.InjectFrom(user);
return View(editUser);
}
return HttpNotFound("User Not Found");
}
示例2: Security
public ActionResult Security(int id)
{
var user = UserService.GetByID(id);
var model = new UserViewModel();
model.InjectFrom<UnflatLoopValueInjection>(user);
model.Username = user.Username;
return View(model);
}
示例3: Display
public ActionResult Display(string username)
{
User user = _authManager.GetUser(username);
if (user == null)
{
return HttpNotFound("User Not Found");
}
var viewModel = new UserViewModel();
viewModel.InjectFrom(user); // value injecter
return View(viewModel);
}