当前位置: 首页>>代码示例>>C#>>正文


C# Users.GetByUserName方法代码示例

本文整理汇总了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;
        }
开发者ID:jhuerta,项目名称:EnduranceGoals.com,代码行数:32,代码来源:GoalEntityBuilder.cs

示例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));
        }
开发者ID:jhuerta,项目名称:EnduranceGoals.com,代码行数:14,代码来源:MembershipController.cs

示例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));
        }
开发者ID:jhuerta,项目名称:EnduranceGoals.com,代码行数:19,代码来源:MembershipController.cs


注:本文中的Users.GetByUserName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。