本文整理汇总了C#中IUserRepository.GetVotes方法的典型用法代码示例。如果您正苦于以下问题:C# IUserRepository.GetVotes方法的具体用法?C# IUserRepository.GetVotes怎么用?C# IUserRepository.GetVotes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserRepository
的用法示例。
在下文中一共展示了IUserRepository.GetVotes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserModule
public UserModule(IUserRepository users, IIdeaRepository ideas, IFeatureRepository features)
{
_users = users;
_ideas = ideas;
_features = features;
this.RequiresAuthentication();
Get["/profile"] = _ =>
{
User user = Context.GetCurrentUser(_users);
if (user == null) return Response.AsRedirect("/");
var i = _ideas.GetAll().Where(u => u.Author.Id == user.Id).ToList();
var f = _features.GetAll().Where(u => u.User.Id == user.Id).ToList();
var v = _users.GetVotes(user.Id).ToList();
return View["Profile/Index",
new
{
Title = "Profile",
Id = user.Id,
UserName = user.UserName,
Email = user.Email,
Github = user.Github,
Ideas = i,
Features = f,
Votes = v,
Claims = user.Claims.ToList(),
IsLoggedIn = Context.IsLoggedIn()
}];
};
Get["/profile/edit"] = _ =>
{
User user = Context.GetCurrentUser(_users);
if (user == null) return Response.AsRedirect("/");
return View["Profile/Edit", new
{
Title = "Profile",
Id = user.Id,
UserName = user.UserName,
Email = user.Email,
Github = user.Github,
Claims = user.Claims.ToList(),
IsLoggedIn = Context.IsLoggedIn(),
}];
};
Post["/profile/checkuser"] = _ =>
{
string username = Request.Form.username;
var userExists = _users.FindBy(u => u.UserName == username).Any();
string msg = "";
if (username == Context.CurrentUser.UserName)
msg = "";
else if (string.IsNullOrWhiteSpace(username))
msg = Strings.UserModule_UsernameNotValid;
else if (userExists)
msg = Strings.UserModule_UsernameTaken;
else msg = Strings.UserModule_UsernameAvailable;
return Response.AsJson(new
{
Status = "OK",
msg = msg
});
};
Post["/profile/save"] = _ =>
{
var user = Context.GetCurrentUser(_users);
user.UserName = Request.Form.username;
user.Email = Request.Form.email;
user.AvatarUrl = user.Email.ToGravatarUrl(40);
user.Github = Request.Form.github;
_users.Edit(user);
return Response.AsRedirect("/profile");
};
}