本文整理汇总了C#中IUserService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.Get方法的具体用法?C# IUserService.Get怎么用?C# IUserService.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyAccountModule
public MyAccountModule(IUserService userService, IMappingEngine mappingEngine)
: base("data/users", mappingEngine, UserRole.Standard)
{
Get["/myAccount"] = args =>
{
var authorizedUser = Context.GetAuthorizedUser();
var foundUser = userService.Get(authorizedUser.Id);
return MapTo<User>(foundUser);
};
Put["/myAccount"] = args =>
{
var model = this.BindAndValidate<Models.User>();
if (!ModelValidationResult.IsValid)
{
return RespondWithValidationFailure(ModelValidationResult);
}
var authorizedUser = Context.GetAuthorizedUser();
var updateEntity = MapTo<SystemUser>(model);
var updatedUser = userService.UpdateUser(authorizedUser.Id, authorizedUser.Id, updateEntity);
Context.SetupSession(updatedUser);
return MapTo<User>(updatedUser);
};
}
示例2: ToPublicModel
public static SponsorPublicModel ToPublicModel(this Sponsor sponsor, IUserService userService, IMediaService pictureService, ISponsorService sponsorService, IFormatterService formatterService, MediaSettings mediaSettings)
{
var user = userService.Get(sponsor.UserId);
if (user == null)
return null;
//get sponsor data
var sponsorData = sponsorService.GetSponsorData(sponsor.BattleId, sponsor.BattleType, sponsor.UserId);
var model = new SponsorPublicModel
{
SponsorshipStatus = sponsor.SponsorshipStatus,
SponsorshipStatusName = sponsor.SponsorshipStatus.ToString(),
CustomerId = sponsor.UserId,
SeName = user.GetPermalink().ToString(),
SponsorName = user.GetPropertyValueAs<string>(PropertyNames.DisplayName),
SponsorProfileImageUrl =
pictureService.GetPictureUrl(user.GetPropertyValueAs<int>(PropertyNames.DefaultPictureId)),
SponsorshipAmount = sponsor.SponsorshipAmount,
SponsorshipAmountFormatted = formatterService.FormatCurrency(sponsor.SponsorshipAmount, ApplicationContext.Current.ActiveCurrency),
SponsorData = sponsorData.ToModel(pictureService),
SponsorshipType = sponsor.SponsorshipType
};
return model;
}
示例3: UserModule
public UserModule(IUserService userService, IMappingEngine mappingEngine)
: base("data/users", mappingEngine, UserRole.Admin)
{
Get["/"] = args =>
{
var entities = userService.Search(
Context.RequestedPage(),
null,
Context.SortCriteria<User>(),
Context.SearchTerms<User>());
return MapToResultList<SystemUser, Encore.Web.Models.User>(entities);
};
Get["/{id}"] = args =>
{
var entity = userService.Get(new Guid(args.id));
if (entity == null)
{
return Negotiate.WithStatusCode(HttpStatusCode.NotFound);
}
return MapTo<Encore.Web.Models.User>(entity);
};
Put["/{id}"] = args =>
{
var model = this.BindAndValidate<Models.User>();
if (!ModelValidationResult.IsValid)
{
return RespondWithValidationFailure(ModelValidationResult);
}
var authorizedUser = Context.GetAuthorizedUser();
var updateEntity = MapTo<SystemUser>(model);
var updateId = new Guid(args.id);
var updatedUser = userService.UpdateUser(authorizedUser.Id, updateId, updateEntity);
if (authorizedUser.Id == updateId)
{
Context.SetupSession(updatedUser);
}
return MapTo<User>(updatedUser);
};
Post["/"] = args =>
{
var model = this.BindAndValidate<Models.User>();
if (!ModelValidationResult.IsValid)
{
return RespondWithValidationFailure(ModelValidationResult);
}
var addEntity = MapTo<SystemUser>(model);
var user = userService.Add(addEntity);
if (user == null)
{
return HttpStatusCode.Unauthorized;
}
return MapTo<User>(user);
};
Delete["/{id}"] = args =>
{
var authorizedUser = Context.GetAuthorizedUser();
var deleteId = new Guid(args.id);
return userService.DeleteUser(authorizedUser.Id, deleteId);
};
}