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


C# UserRepository类代码示例

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


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

示例1: TestMethod1

        public void TestMethod1()
        {
            var dbContext = new DanwuDbContext();
            var context = new EntityFrameworkRepositoryContext();
            var unitOfWork = new EntityFrameworkUnitOfWork(dbContext);
            IUserRepository userRepository = new UserRepository(context);
            userRepository.Create(new User()
            {
                UserName = "wudan",
                NickName = "坏坏男孩",
                RealName = "吴丹",
                PhoneNum = "18916765826",
                Email = "[email protected]",
                Status = UserStatus.Enabled,
                PassWord = "123456",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });
            userRepository.Create(new User()
            {
                UserName = "wudan1",
                NickName = "坏坏男孩1",
                RealName = "吴丹1",
                PhoneNum = "18916765000",
                Email = "[email protected]",
                Status = UserStatus.Disabled,
                PassWord = "123456",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });

            var result = context.Commit();
            //var result = unitOfWork.Commit();
        }
开发者ID:wudan330260402,项目名称:Danwu.Core,代码行数:34,代码来源:UnitTest1.cs

示例2: GetUCError

        public List<Guid> GetUCError()
        {
            List<Guid> ret = new List<Guid>();
            using (UserRepository repo = new UserRepository())
            {
                foreach(var v in repo.GetAllUserAcadmic())
                {
                    if(!string.IsNullOrEmpty(v.Association) && string.IsNullOrEmpty(v.AssociationPost))
                    {
                        if (!ret.Contains(v.AccountEmail_uuid))
                            ret.Add(v.AccountEmail_uuid);
                    }

                    if (!string.IsNullOrEmpty(v.Magazine) && string.IsNullOrEmpty(v.MagazinePost))
                    {
                        if (!ret.Contains(v.AccountEmail_uuid))
                            ret.Add(v.AccountEmail_uuid);
                    }


                    if (!string.IsNullOrEmpty(v.Fund) && string.IsNullOrEmpty(v.FundPost))
                    {
                        if (!ret.Contains(v.AccountEmail_uuid))
                            ret.Add(v.AccountEmail_uuid);
                    }
                }
            }
            return ret;
        }
开发者ID:amwtke,项目名称:bkwecaht,代码行数:29,代码来源:WeixinApiController2.cs

示例3: GetRolesForUser

        public override string[] GetRolesForUser(string login)
        {
            string[] role = new string[] { };
            using (IModelRepository<User> _user = new UserRepository())
            {
                try
                {
                    IModelRepository<Role> _role = new RoleRepository();
                    // Get User
                    var user = (from u in _user.Items
                                 where u.Login == login
                                 select u).FirstOrDefault();
                    if (user != null)
                    {
                        // Get role
                        var userRole = _role.Items.FirstOrDefault(x=>x.Id==user.RoleId);

                        if (userRole != null)
                        {
                            role = new string[] { userRole.Name };
                        }
                    }
                }
                catch
                {
                    role = new string[] { };
                }
            }
            return role;
        }
开发者ID:na2sia,项目名称:CheckPoint,代码行数:30,代码来源:MyRoleProvider.cs

示例4: UserService

        public UserService()
        {
            _userManager = _userManager ?? new ApplicationUserManager(new UserStore<ApplicationUserEntity>());
            _userRepository = _userRepository ?? new UserRepository<ApplicationUserEntity>();

            UserMappingConfig.RegisterMappings();
        }
开发者ID:tahtarov,项目名称:gspd-chat,代码行数:7,代码来源:UserService.cs

示例5: AccountController

 public AccountController(IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     _repository = new UserRepository(unitOfWork);
     _departRepository= new DepartRepository(unitOfWork);
     _roleRepository = new RoleRepository(unitOfWork);
 }
开发者ID:bearing09,项目名称:Jspm,代码行数:7,代码来源:AccountController.cs

示例6: GroupMemberService

 public GroupMemberService(
         UserRepository userRepository,
         GroupRepository groupRepository)
 {
     this.GroupRepository = groupRepository;
     this.UserRepository = userRepository;
 }
开发者ID:piotrpasich,项目名称:IDDD_Samples_NET,代码行数:7,代码来源:GroupMemberService.cs

示例7: GetById_UserDoesNotExist

        public void GetById_UserDoesNotExist()
        {
            var repository = new UserRepository(_contextFactory);

            var retrievedUser = repository.GetById(123);
            Assert.IsNull(retrievedUser);
        }
开发者ID:eugene-blokhin,项目名称:EasyRead,代码行数:7,代码来源:UserRepositoryTest.cs

示例8: OnActionExecutedAsync

        public override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
        {
            //加入访问次数
            foreach (var v in getActionArgumentsValues(actionExecutedContext))
            {
                if (v is DualParameter)
                {
                    var u = v as DualParameter;
                    NameCardAccessCountOP.AddScore(u.uuid.ToString(), 1);
                    using (UserRepository repo = new UserRepository())
                    {
                        UserInfo user = repo.GetUserInfoByUuid_TB(u.uuid);
                        if(user!=null)
                        {
                            if(user.IsBusiness!= null)
                            {
                                if (user.IsBusiness == 0)
                                    new RedisManager2<WeChatRedisConfig>().AddScoreAsync<NameCardRedis, NameCardPCountZsetAttribute>(u.uuid.ToString(), 1);
                                else if(user.IsBusiness==2)
                                    new RedisManager2<WeChatRedisConfig>().AddScoreAsync<NameCardRedis, NameCardSCountZsetAttribute>(u.uuid.ToString(), 1);
                            }

                        }
                    }
                    break;
                }
            }
            return base.OnActionExecutedAsync(actionExecutedContext, cancellationToken);
        }
开发者ID:amwtke,项目名称:bkwecaht,代码行数:29,代码来源:UserRelatedWebApiFilter.cs

示例9: GetUserRepository

        protected override IUserRepository GetUserRepository()
        {
            var userRepository = new UserRepository(this.repositoryStrategy);
            userRepository.RepositoryGlass = new UserRepositoryGlass();

            return userRepository;
        }
开发者ID:juanonsoftware,项目名称:gdnet-webframework,代码行数:7,代码来源:DataRepositories.cs

示例10: IsAdmin

        public static Boolean IsAdmin(this IPrincipal principal)
        {
            UserRepository userRepository = new UserRepository();

            User user = userRepository.GetBy(x => x.Email == principal.Identity.Name);
            return user != null && user.Role == Role.Admin;
        }
开发者ID:julia-homa,项目名称:Travel_business,代码行数:7,代码来源:IdentityExtensions.cs

示例11: Execute

        public override bool Execute(string input)
        {
            if (String.IsNullOrEmpty(input)) return false;

            var repository = new UserRepository();
            int userId;
            if (!Int32.TryParse(input, out userId))
            {
                return false;
            }

            var user = repository.GetById(userId);
            if (user != null)
            {
                repository.Delete(user);
            }
            try
            {
                repository.SaveChanges();
                Success = true;
            }
            catch
            {
                Success = false;
            }
            return Success;
        }
开发者ID:Choulla-Naresh8264,项目名称:WebGridExample,代码行数:27,代码来源:DeleteUserCommand.cs

示例12: ReturnsTrueIfEmailExistsForDifferentUser

 public void ReturnsTrueIfEmailExistsForDifferentUser()
 {
     var repository = new UserRepository(null, SessionSource.CreateSession());
     var user = new User { Name = "test", Credentials = new Credentials("[email protected]", "pass") };
     repository.Save(new User {Name = "test", Credentials = new Credentials("[email protected]", "pass")});
     Assert.True(repository.EmailExists(user));
 }
开发者ID:okeulder,项目名称:codebettercanvas,代码行数:7,代码来源:EmailExistsTests.cs

示例13: CreateUser

        public static BaseActionResult CreateUser(User obj4create)
        {
            string msg;
            if (obj4create == null)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_USER) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new UserRepository(context);
                    string newId = Guid.NewGuid().ToString();
                    obj4create.Id = newId;
                    repository.Create(obj4create);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.Name);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.Name) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
开发者ID:neilchennan,项目名称:Xiaolu,代码行数:28,代码来源:BusinessService.User.cs

示例14: BulkDeleteUserByIds

        public static BaseActionResult BulkDeleteUserByIds(string idsStr)
        {
            string msg;
            string[] idArr = idsStr.Split(',');
            if (idArr.Length == 0)
            {
                msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION;
                return new BaseActionResult(false, msg);
            }
            try
            {
                List<User> list4delete = new List<User>();
                foreach (string id in idArr)
                {
                    var obj4delete = GetUserById(id);
                    list4delete.Add(obj4delete);
                }

                using (var context = new XiaoluEntities())
                {
                    var repository = new UserRepository(context);
                    repository.BulkDelete(list4delete);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_USER, idArr.Length);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg, e);
            }
        }
开发者ID:neilchennan,项目名称:Xiaolu,代码行数:33,代码来源:BusinessService.User.cs

示例15: Delete

        public ActionResult Delete(int id)
        {
            UserRepository userRep = new UserRepository();
            userRep.Delete(id);

            return RedirectToAction("List");
        }
开发者ID:AntonCholakov,项目名称:CHSystem,代码行数:7,代码来源:UsersController.cs


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