本文整理汇总了C#中Users.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Users.Get方法的具体用法?C# Users.Get怎么用?C# Users.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users.Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmailExist
private bool EmailExist(string email)
{
dynamic u = new Users();
//return u.Get().Where(x => x.Email == email).Count() == 1;
var v =u.Get(Email: email);
return v.Count() == 1;
}
示例2: UsersEndpoint
public UsersEndpoint(Users users, Commits commits, AppSettings settings, DcsScm scm)
: base("/users")
{
Get["/"] = _ =>
{
string token = Request.Query.token;
if (token.ToNullableGuid() != FakeyAuth.Token)
{
return new Response
{
StatusCode = HttpStatusCode.Forbidden
};
}
return users.GetAll()
.Select(u =>
{
var user = new
{
Username = u.Username,
u.Id
};
return user;
}
);
};
Get["/{userId}"] = _ =>
{
var user = users.Get((Guid) _.userId);
if (user == null)
{
return new NotFoundResponse();
}
var repo = user.Repositories.FirstOrDefault();
return new
{
Username = user.Username,
user.Id,
user.Email,
RepositoryHref = repo == null ? null : scm.GetRepoUrl(repo.Name, user, true),
Challenges = user.Challenges.Select(c =>
new {
c.Name,
c.StageNumber,
c.RepositoryId
})
};
};
Get["/{userId}/commits"] = _ =>
commits.ForUser((Guid) _.userId)
.OrderByDescending(c => c.CommittedAt)
.Select(c =>
new
{
c.Id,
c.CommittedAt,
c.UserId,
c.Username,
c.RepositoryId,
c.RepositoryName,
c.Challenge,
c.CurrentStageNumber,
c.ResultsUpdatedAt,
c.Outcome,
c.OutcomeDetail,
HasTestOutput = !string.IsNullOrEmpty(c.TestOutput)
});
}