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


C# UserRepository.Get方法代码示例

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


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

示例1: UserExample

        public void UserExample()
        {
            var interests = new HashSet<string> { "distributed systems", "Erlang" };
            var joe = new User("Joe", "Armstrong", interests);

            var entityManager = new EntityManager(client);
            entityManager.Add(joe);
            var repo = new UserRepository(client);
            repo.Save(joe);

            joe.VisitPage();

            joe.AddInterest("riak");

            repo.UpgradeAccount(joe);

            var joeFetched = repo.Get(joe.ID);

            Assert.GreaterOrEqual(joe.PageVisits, 0);
            Assert.Contains("riak", joeFetched.Interests.ToArray());

            PrintObject(joeFetched);

            repo.DowngradeAccount(joe);

            joeFetched = repo.Get(joe.ID);
            PrintObject(joeFetched);
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:28,代码来源:DataTypes.cs

示例2: Index

        public ViewResult Index(string Name, string Email, string Password)
        {
            try
            {
                UserRepository userRep = new UserRepository();
                Expression<Func<t_user, bool>> filter =
                x => (x.mail == Email && Email != null);
                List<t_user> users = userRep.Get(filter).ToList();
                LoginModel model = new LoginModel();

                if (users.Count > 0)
                {
                    return View(model);
                }
                else
                {
                    t_user newUser = new t_user();
                    newUser.name = Name;
                    newUser.mail = Email;
                    newUser.password = Password;
                    newUser.roleID = 2;
                    userRep.Save(newUser);

                    model.Name = Name;
                    model.Email = Email;
                    model.Password = Password;
                }

                return View(model);
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:lxsndr33,项目名称:Auction,代码行数:35,代码来源:UserController.cs

示例3: IsLoggedInIsFalseWhenValueIsMissingFromConfiguration

        public void IsLoggedInIsFalseWhenValueIsMissingFromConfiguration()
        {
            var watchingConfigRepoMock = MockRepository.GenerateMock<IWatchingConfigurationRepository>();
            var repository = new UserRepository(watchingConfigRepoMock);
            var mockConfig = MockRepository.GenerateMock<IConfigurationElement>();
            mockConfig.Stub(x => x.Attributes).Return(new Dictionary<string, string>());
            var mockFriendsConfig = MockRepository.GenerateMock<IConfigurationElement>();
            mockFriendsConfig.Stub(x => x.Name).Return("friends");
            mockFriendsConfig.Stub(x => x.Attributes).Return(new Dictionary<string, string>()
            {
                { "PersonaName", "User Name" },
            });
            var mockProfileDetailConfig = MockRepository.GenerateMock<IConfigurationElement>();
            mockProfileDetailConfig.Stub(x => x.Name).Return("123");
            mockProfileDetailConfig.Stub(x => x.Attributes).Return(new Dictionary<string, string>()
            {
                { "name", mockFriendsConfig.Attributes["PersonaName"] }
            });
            mockFriendsConfig.Stub(x => x.Children).Return(new[] { mockProfileDetailConfig });
            mockConfig.Stub(x => x.Children).Return(new[] { mockFriendsConfig });

            watchingConfigRepoMock.Raise(x => x.Added += delegate { }, mockConfig);

            var user = repository.Get().FirstOrDefault();
            Assert.IsNotNull(user);

            Assert.AreEqual(int.Parse(mockProfileDetailConfig.Name), user.Id);
            Assert.AreEqual(mockProfileDetailConfig.Attributes["name"], user.Name);
            Assert.AreEqual(false, user.IsLoggedIn);
        }
开发者ID:Neurosion,项目名称:SteamLauncher,代码行数:30,代码来源:UserRepositoryTests.cs

示例4: OrderDetails

        public void OrderDetails()
        {
            var conn = new NHibernateConnection();
            var orderRepo = new OrdersRepository(conn);
            var productRepo = new ProductsRepository(conn);
            var userRepo = new UserRepository(conn);
            var deliveryRepo = new DeliveryTypesRepository(conn);
            Users user = userRepo.Get("[email protected]");
            var orderDetailsRepo = new OrderDetailsRepository(conn);
            Products product = productRepo.GetAll().First();

            var delivetyType = deliveryRepo.GetAll().First();

            if (delivetyType == null)
            {
                delivetyType = new DeliveryTypes("Poczta Polska", Convert.ToDecimal(8.99));
                deliveryRepo.Save(delivetyType);
            }

            var order = new Orders(user, DateTime.Now,
                Convert.ToDecimal(299.99),delivetyType);

            orderRepo.Save(order);

            var orderDetails = new OrderDetails(order, product, 2, Convert.ToDecimal(29.99));
            orderDetailsRepo.Save(orderDetails);

            var fromDB = orderDetailsRepo.Get(orderDetails.ID);

            Assert.IsNotNull(fromDB);
        }
开发者ID:gpierzchala,项目名称:InternetStore,代码行数:31,代码来源:DataAccessTests.cs

示例5: GetMySql

 public static void GetMySql()
 {
     UserRepository rep = new UserRepository(new MySqlDbContext());
     rep.Insert(new User { ID = new Guid("12736219-9398-4DBD-A392-BF8C5CCC3635"), Mobile = "01819421877", Password = "NewPassword", Username = "SiamDeath" });
     rep.Commit();
     var data = rep.Get(new Guid("C1C8D804-0645-4006-B9C8-192EBD944944"));
     var collection = rep.GetAll().ToList();
 }
开发者ID:LudwigLei,项目名称:MSSQL-MySql-Mongo-Repository-withEF6,代码行数:8,代码来源:Program.cs

示例6: GetSql

        public static void GetSql()
        {
            UserRepository rep = new UserRepository(new WebApiDBContext());
            rep.Insert(new User { ID = new Guid("19D40AEC-37B7-4114-A5BF-E4E3B3CFC97A"), Mobile = "01819421877", Password = "NewPassword", Username = "SiamDeath" });
            rep.Commit();

            var data = rep.Get(new Guid("C1C8D804-0645-4006-B9C8-192EBD944944"));
            var collection = rep.GetAll().ToList();

        }
开发者ID:LudwigLei,项目名称:MSSQL-MySql-Mongo-Repository-withEF6,代码行数:10,代码来源:Program.cs

示例7: TestGet_InitializeNoUsers_ShouldReturnNull

        public void TestGet_InitializeNoUsers_ShouldReturnNull()
        {
            // Arrange
            var roomsRepo = new UserRepository();

            // Act
            var user = roomsRepo.Get(1);

            // Assert
            Assert.IsNull(user);
        }
开发者ID:eslavov11,项目名称:SoftUni-Homework,代码行数:11,代码来源:RepositoryTests.cs

示例8: getUserId

 public int getUserId(string name)
 {
     UserRepository user_rep = new UserRepository();
     int user_id = -1;
     User user = user_rep.Get(u => u.Email == name);
     if (user != null)
     {
         user_id = user.Id;
     }
     return user_id;
 }
开发者ID:SalamanderSunburn,项目名称:Phonebook,代码行数:11,代码来源:UserService.cs

示例9: ChangeIDCard

 public void ChangeIDCard(string userName, string idCardNo, string chineseName)
 {
     using (UserRepository userRepository = new UserRepository())
     {
         var user = userRepository.Get(userName);
         if (user != null)
         {
             user.ChangeIDCard(idCardNo, chineseName);
             userRepository.Commit();
         }
     }
 }
开发者ID:BruceZhangGit,项目名称:UniversityDream,代码行数:12,代码来源:UserAppService.cs

示例10: ActivateAccountTest

 public void ActivateAccountTest()
 {
     IUserService accountSrv = new UserService();
     UserAppService target = new UserAppService(accountSrv);
     using (UserRepository repository = new UserRepository())
     {
         Guid accountId = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818");
         var account = repository.Get(accountId);
         string activationCode = account.ActivationCode;
         target.ActivateAccount(accountId, activationCode);
         repository.Refresh(account);
         Assert.AreEqual(account.IsActive, true);
     }
 }
开发者ID:BruceZhangGit,项目名称:UniversityDream,代码行数:14,代码来源:AccountAppServiceTest.cs

示例11: TestGet_InitializeValidUsers_PasswordsShouldMatch

        public void TestGet_InitializeValidUsers_PasswordsShouldMatch()
        {
            // Arrange
            var roomsRepo = new UserRepository();
            roomsRepo.Add(new User("username1", "password123", Roles.User));
            roomsRepo.Add(new User("username2", "password1234", Roles.VenueAdmin));
            roomsRepo.Add(new User("username3", "password123", Roles.User));

            // Act
            var user = roomsRepo.Get(2);

            // Assert
            Assert.AreEqual(HashUtilities.GetSha256Hash("password1234"), user.PasswordHash, "Passwords don't match.");
        }
开发者ID:eslavov11,项目名称:SoftUni-Homework,代码行数:14,代码来源:RepositoryTests.cs

示例12: DeleteUser

        public bool DeleteUser(int id)
        {
            UserRepository repo = new UserRepository(entities);
            User user = repo.Get(id);

            try {
                repo.Delete(user);
                return true;
            }
            catch (Exception ex) {
                _errorMessage = ex.Message;
                return false;
            }
        }
开发者ID:adramalech,项目名称:KolabApp,代码行数:14,代码来源:UsersService.cs

示例13: TestGet_InitializeValidUsers_UsernamesShouldMatch

        public void TestGet_InitializeValidUsers_UsernamesShouldMatch()
        {
            // Arrange
            var roomsRepo = new UserRepository();
            roomsRepo.Add(new User("username1", "password123", Roles.User));
            roomsRepo.Add(new User("username2", "password123", Roles.VenueAdmin));
            roomsRepo.Add(new User("username3", "password123", Roles.User));

            // Act
            var user = roomsRepo.Get(2);

            // Assert
            Assert.AreEqual("username2", user.Username, "Usernames don't match.");
        }
开发者ID:eslavov11,项目名称:SoftUni-Homework,代码行数:14,代码来源:RepositoryTests.cs

示例14: GetUserData

        public JsonResult GetUserData(string page, string sidx, string sord)
        {
            var repo = new UserRepository();

            var jqGridUserDto = new JqGridUserDto()
            {
                Data = repo.Get(),
                Page = page,
                PageSize = 5,
                SortColumn = sidx,
                SortOrder = sord
            };

            return Json(jqGridUserDto, JsonRequestBehavior.AllowGet);
        }
开发者ID:Vethro,项目名称:Learning,代码行数:15,代码来源:HomeController.cs

示例15: CreateApplication

        public void CreateApplication(Domain.Context.Application application)
        {
            if (application == null)
                throw new ArgumentNullException("application");

            using (UserRepository userRepository = new UserRepository())
            {
                var user = userRepository.Get(application.UserId);

                if (user != null)
                {
                    var achievement = user.Achievements.SingleOrDefault<Achievement>(a => a.Year == DateTime.Now.Year);
                    if (achievement != null)
                    {
                        //using (SpecialityEnrollPlanRepository enrollPlanRepository = new SpecialityEnrollPlanRepository())
                        //{
                        //    var enrollPlans = enrollPlanRepository.GetFiltered(e => e.SpecialityId == application.SpecialityId && e.Province == achievement.Province).SingleOrDefault<SpecialityEnrollPlan>();
                        //    if (enrollPlans != null)
                        //    {
                        using (ApplicationRepository appRepository = new ApplicationRepository())
                        {
                            var apps = appRepository.GetFiltered(app => app.Year == application.Year && app.Batch == application.Batch && app.ApplicationSequence == application.ApplicationSequence);
                            if (apps != null && apps.ToList<Domain.Context.Application>().Count > 0)
                            {
                                // throw existing application exception
                                throw new UniversityApplicationExistException(Resource.UserMessages.ex_UniversityApplicationExist);
                            }
                            appRepository.Add(application);
                            appRepository.Commit();
                        }
                        //}
                        //else
                        //{
                        //    // throw no enroll plan exception
                        //    throw new UniversityNoEnrollPlanException(Resource.ResourceMessage.ex_UnversityNoEnrollPlan);
                        //}
                        //}
                    }
                    else
                    {
                        throw new UniversityApplicationExistException(Resource.UserMessages.ex_AchievementNotExist);
                    }
                }
            }
        }
开发者ID:BruceZhangGit,项目名称:UniversityDream,代码行数:45,代码来源:ApplicationService.cs


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