本文整理汇总了C#中IUserService.GetUserById方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.GetUserById方法的具体用法?C# IUserService.GetUserById怎么用?C# IUserService.GetUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.GetUserById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserModule
public UserModule(IUserService userService):base("/users")
{
Get["/{id}", true] = async (ctx, cancel) =>
{
var request = this.Bind<GetUserByIdRequest>();
var user = await userService.GetUserById(new GetUserById()
{
Id = request.Id
});
return Response.AsJson(user);
};
Post["/", true] = async (ctx, cancel) =>
{
var request = this.Bind<CreateUserRequest>();
var user = await userService.CreateUser(new CreateUser()
{
HourlyRate = request.HourlyRate,
Salary = request.Salary
});
return Response.AsJson(user);
};
}
示例2: User_Saving
/// <summary>
/// User saving event.
/// </summary>
/// <remarks>
/// User is already saved but the object itself is not updated yet.
/// </remarks>
void User_Saving(IUserService service, SaveEventArgs<IUser> e)
{
foreach (var savedEntity in e.SavedEntities)
{
if (savedEntity != null)
{
if (!savedEntity.IsNewEntity())
{
// Update permissions for old users if the user type changes.
IUser savedUser = service.GetUserById(savedEntity.Id);
if (savedEntity.UserType.Alias != savedUser.UserType.Alias)
{
_userTypePermissionsService.CopyPermissionsForSingleUser(savedUser);
}
}
else
{
// Set permissions for new users.
_userTypePermissionsService.CopyPermissionsForSingleUser(savedEntity);
}
}
}
}
示例3: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
_userService = IoC.Resolve<IUserService>();
if (this.Page is GeneralPage && this._userId > 0)
{
GeneralPage page = (GeneralPage)this.Page;
try
{
User user = _userService.GetUserById(this._userId);
this.litTitle.Text = String.Format(GetTextFromFile("VIEWPROFILETITLE"), user.UserName);
BindUser(user);
if (! this.IsPostBack)
{
// Databind is required to bind the localized resources.
this.DataBind();
}
}
catch
{
this.lblError.Text = String.Format(GetTextFromFile("USERNOTFOUND"), this._userId.ToString());
this.lblError.Visible = true;
}
}
}