• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UserRepository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PostChatCenterInitialize

        public async Task<HttpResponseMessage> PostChatCenterInitialize([FromBody]BaseParameter postParameter)
        {
            string openid = postParameter.openID;
            if(string.IsNullOrEmpty(openid))
            {
                return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
            }
            using(UserRepository userRepository = new UserRepository())
            {
                var uuid = await userRepository.GetUserUuidByOpenid(openid);
                var sessions = await MessageRedisOp.GetSessionsTimeStampByUuid(uuid.ToString().ToUpper(), Order.Descending, 0, -1);
                List<Tuple<double, UserInfo, string>> ChatCenterList = new List<Tuple<double, UserInfo, string>>();
                foreach(var s in sessions)
                {
                    double unreadNum = await MessageRedisOp.GetUnreadScore(uuid.ToString().ToUpper(), s.Key);
                    List<string> uuidPair = await MessageRedisOp.GetUUidsBySessionId(s.Key);
                    string userUuid = uuidPair[0] == uuid.ToString().ToUpper() ? uuidPair[1] : uuidPair[0];

                    Guid userGUID;
                    if(!Guid.TryParse(userUuid, out userGUID) || userGUID.Equals(Guid.Empty))
                        continue;
                    UserInfo toUser = await userRepository.GetUserInfoByUuidAsync(userGUID);

                    var latestMessage = await WeChatReceiveHelper.GetFirstMessagesFromRedis(uuid.ToString().ToUpper(), userUuid.ToUpper());
                    ChatCenterList.Add(Tuple.Create(unreadNum, toUser, latestMessage));
                }
                return WebApiHelper.HttpRMtoJson(ChatCenterList, HttpStatusCode.OK, customStatus.Success);
            }
        }
开发者ID:amwtke,项目名称:bkwecaht,代码行数:29,代码来源:ChatController.cs


示例17: Edit

        public ActionResult Edit(int? id)
        {
            User user;
            UserRepository userRep = new UserRepository();

            if (!id.HasValue)
            {
                user = new User();
            }
            else
            {
                user = userRep.GetByID(id.Value);
                if (user == null)
                {
                    return RedirectToAction("List");
                }
            }

            UsersEditVM model = new UsersEditVM();
            model.ID = user.ID;
            model.Username = user.Username;
            model.FirstName = user.FirstName;
            model.LastName = user.LastName;
            model.Email = user.Email;
            model.Groups = PopulateAssignedGroups(user);

            return View(model);
        }
开发者ID:AntonCholakov,项目名称:CHSystem,代码行数:28,代码来源:UsersController.cs


示例18: Base_Inheritance_Save

 public void Base_Inheritance_Save()
 {
     var repository = new UserRepository();
     var user = new User {Name = "Base_Inheritance_Save"};
     repository.Add(user);
     repository._collectionName.Should().Be("User");
 }
开发者ID:offkiltercode,项目名称:ProMongoRepository,代码行数:7,代码来源:Inheritance_Tests.cs


示例19: GetService

 private static UserService GetService()
 {
     IServiceLocator serviceLocator = new DummyServiceLocator();
     IUserRepository userRepository = new UserRepository(serviceLocator);
     IUnitOfWork uow = new EfUnitOfWork<SampleDataContext>(serviceLocator);
     return new UserService(uow, userRepository);
 }
开发者ID:ziyasal,项目名称:RepositoryT.EntityFramework,代码行数:7,代码来源:Program.cs


示例20: AddUserMessage

        public void AddUserMessage()
        {
            using (var uow = new CapriconContext())
            {
                //retreive an existing user
                var userRepository = new UserRepository(uow);
                var existingUser = userRepository.GetAll().FirstOrDefault();

                Assert.IsNotNull(existingUser);

                //retreive an existing message
                var messageRepository = new MessageRepository(uow);
                var existingMessage = messageRepository.GetAll().FirstOrDefault();

                Assert.IsNotNull(existingMessage);

                //create new user messsage
                var newUserMessage = new UserMessage()
                {
                    User = existingUser,
                    Message = existingMessage
                };

                //add the new user message to the repository
                var userMessageRepository = new UserMessageRepository(uow);
                userMessageRepository.Add(newUserMessage);

                try
                {
                    uow.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    //Retrieve validation errors
                    ex.EntityValidationErrors.ToList().ForEach
                    (
                        v =>
                        {
                            v.ValidationErrors.ToList().ForEach
                                (
                                    e =>
                                    {
                                        System.Diagnostics.Debug.WriteLine(e.ErrorMessage);
                                    }
                                );
                        }
                    );

                    Assert.Fail("Test failed");
                }

                //retrieve saved object
                var uow1 = new CapriconContext();
                var repository = new UserMessageRepository(uow1);
                var savedUserMessages = repository.GetAll().ToList();

                Assert.AreEqual(savedUserMessages[0].User.FirstName, existingUser.FirstName = "james");
                Assert.AreEqual(savedUserMessages[0].Message.MessageId, existingMessage.MessageId = 1);
            };
        }
开发者ID:shyakaster,项目名称:CARPRICONRELOADED,代码行数:60,代码来源:UserMessageTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UserRequestProcessor类代码示例发布时间:2022-05-24
下一篇:
C# UserProfileData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap