本文整理汇总了C#中Users.GetByUserName方法的典型用法代码示例。如果您正苦于以下问题:C# Users.GetByUserName方法的具体用法?C# Users.GetByUserName怎么用?C# Users.GetByUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users.GetByUserName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutOfGoalViewModel
public Goal OutOfGoalViewModel(GoalViewModel goalViewModel, string username)
{
Sports sports = new Sports(SessionProvider.CurrentSession);
Venues venues = new Venues(SessionProvider.CurrentSession);
Goals goals = new Goals(SessionProvider.CurrentSession);
Users users = new Users(SessionProvider.CurrentSession);
Goal goal;
if(goalViewModel.Id == 0)
{
goal = new Goal();
goal.CreatedOn = DateTime.Now;
goal.UserCreator = users.GetByUserName(username);
}
else
{
goal = goals.GetById(goalViewModel.Id);
}
goal.Name = goalViewModel.Name;
goal.Date = goalViewModel.Date;
goal.Description = goalViewModel.Description;
goal.Web = goalViewModel.Web;
goal.Venue = venues.GetById(Convert.ToInt32(goalViewModel.VenueId));
goal.Sport = sports.GetById(Convert.ToInt32(goalViewModel.SportId));
goal.Venue.Latitude = Convert.ToInt32(goalViewModel.VenueLatitude);
goal.Venue.Longitude = Convert.ToInt32(goalViewModel.VenueLongitude);
return goal;
}
示例2: SubscriptionStatus
public ActionResult SubscriptionStatus(int goalId)
{
var goals = new Goals(SessionProvider.CurrentSession);
var users = new Users(SessionProvider.CurrentSession);
var goal = goals.GetById(goalId);
var user = users.GetByUserName(User.Identity.Name);
if(goal.IsParticipant(user.Username))
{
return View("MembershipWidget", new MembershipManagementViewModel(true, goalId));
}
return View("MembershipWidget", new MembershipManagementViewModel(false, goalId));
}
示例3: Subscribe
public ActionResult Subscribe([Bind(Prefix = "id")] int goalId)
{
var goals = new Goals(SessionProvider.CurrentSession);
var goal = goals.GetById(goalId);
var users = new Users(SessionProvider.CurrentSession);
var user = users.GetByUserName(User.Identity.Name);
goal.Participants.Add(new GoalParticipant()
{
Goal = goal,
User = user,
SignedOnDate = DateTime.Now
});
return View("MembershipWidget", new MembershipManagementViewModel(true, goalId));
}