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


C# UserRepository.GetUserByName方法代码示例

本文整理汇总了C#中UserRepository.GetUserByName方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetUserByName方法的具体用法?C# UserRepository.GetUserByName怎么用?C# UserRepository.GetUserByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserRepository的用法示例。


在下文中一共展示了UserRepository.GetUserByName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Show

        public ActionResult Show(string id)
        {
            var userRepo = new UserRepository(new DataContext());
            User user = userRepo.GetUserByName(id);
            User me = userRepo.GetUserByName(User.Identity.Name);
            ViewBag.CurrentUser = user;

            ViewBag.IsFriends = me.Friends.FirstOrDefault(u => u.FriendId == user.ID) != null;
            if (user != null)
            {
                ViewBag.LastMessage = user.Barks.OrderByDescending(o => o.CreateAt).First();
                //return View(user);
                return View(barkRepository.GetBarksByUser(user.ID).OrderByDescending(t => t.CreateAt));
            }
            return RedirectToAction("Index");
        }
开发者ID:RanDahan,项目名称:barker,代码行数:16,代码来源:HomeController.cs

示例2: ShouldReturnNullWhenUserDoesntExists

        public void ShouldReturnNullWhenUserDoesntExists()
        {
            var repo = new UserRepository();
            repo.CreateUser("some_name", "password", "name", "address", "phone");

            var user = repo.GetUserByName("other_name");

            Assert.IsNull(user);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:9,代码来源:UserRepositoryTest.cs

示例3: Index

 public ActionResult Index()
 {
     var userRepo = new UserRepository(new DataContext());
     User user = userRepo.GetUserByName(User.Identity.Name);
     ViewBag.Followers = userRepo.FollowersCount(user);
     ViewBag.CurrentUser = user;
     ViewBag.LastMessage = user.Barks.OrderByDescending(o=>o.CreateAt).First();
     //return View(user);
     return View(barkRepository.GetBarksByUser(user.ID).OrderByDescending(t => t.CreateAt));
 }
开发者ID:RanDahan,项目名称:barker,代码行数:10,代码来源:HomeController.cs

示例4: ShouldReturnUserByAccountName

        public void ShouldReturnUserByAccountName()
        {
            const string accountName = "user_name";
            var repo = new UserRepository();
            repo.CreateUser(accountName, "password", "name", "address", "phone");

            var user = repo.GetUserByName(accountName);

            Assert.IsNotNull(user);
            Assert.AreEqual(accountName,user.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:11,代码来源:UserRepositoryTest.cs

示例5: Bark

 public ActionResult Bark(string message)
 {
     var userRepo = new UserRepository(new DataContext());
     User user = userRepo.GetUserByName(User.Identity.Name);
     var model = new Bark();
     model.Message = message;
     model.CreateAt = DateTime.Now;
     model.UserID = user.ID;
     if (ModelState.IsValid)
     {
         barkRepository.InsertBark(model);
         barkRepository.Save();
     }
     return RedirectToAction("", "Home");
 }
开发者ID:RanDahan,项目名称:barker,代码行数:15,代码来源:BarksController.cs

示例6: TaggleFollow

        public ActionResult TaggleFollow(string id)
        {
            var userRepo = new UserRepository(new DataContext());
            User me = userRepo.GetUserByName(User.Identity.Name);
            User friend = userRepo.GetUserByID(Guid.Parse(id));
            //var Friends = me.Friends.FirstOrDefault(u => u.FriendId == user.ID);

            if (me.IsFriends(friend))
            {
                me.RemoveFriend(friend);
            }
            else
            {
                me.AddFriend(friend);
            }

            userRepo.Save();

            return RedirectToAction("Show", new {id = friend.Username});
        }
开发者ID:RanDahan,项目名称:barker,代码行数:20,代码来源:HomeController.cs

示例7: UserDetails

        public ActionResult UserDetails()
        {
            var userRepo = new UserRepository(new DataContext());
             User user = userRepo.GetUserByName(User.Identity.Name);
             List<UserFriend> friends = userRepo.FollowersCount(user);

            UserDetailsModel model = new UserDetailsModel { User = user, Followers = friends };

            return PartialView("_SideContents", model);
        }
开发者ID:RanDahan,项目名称:barker,代码行数:10,代码来源:HomeController.cs


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