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

C# DomainModel.MembershipUser类代码示例

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

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



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

示例1: AddPost

        public void AddPost()
        {
            var postRepository = Substitute.For<IPostRepository>();
            var topicRepository = Substitute.For<ITopicRepository>();
            var roleService = Substitute.For<IRoleService>();
            var membershipUserPointsService = Substitute.For<IMembershipUserPointsService>();
            var settingsService = Substitute.For<ISettingsService>();
            settingsService.GetSettings().Returns(new Settings { PointsAddedPerPost = 20 });
            var localisationService = Substitute.For<ILocalizationService>();
            var postService = new PostService(membershipUserPointsService, settingsService, roleService, postRepository, topicRepository, localisationService, _api);

            var category = new Category();
            var role = new MembershipRole{RoleName = "TestRole"};

            var categoryPermissionForRoleSet = new List<CategoryPermissionForRole>
                                                   {
                                                       new CategoryPermissionForRole { Permission = new Permission { Name = AppConstants.PermissionEditPosts }, IsTicked = true},
                                                       new CategoryPermissionForRole { Permission = new Permission { Name = AppConstants.PermissionDenyAccess }, IsTicked = false},
                                                       new CategoryPermissionForRole { Permission = new Permission { Name = AppConstants.PermissionReadOnly  }, IsTicked = false}
                                                   };

            var permissionSet = new PermissionSet(categoryPermissionForRoleSet);
            roleService.GetPermissions(category, role).Returns(permissionSet);

            var topic = new Topic { Name = "Captain America", Category = category};
            var user = new MembershipUser {
                UserName = "SpongeBob",
                Roles = new List<MembershipRole>{role}
            };

            var newPost = postService.AddNewPost("A test post", topic, user, out permissionSet);

            Assert.AreEqual(newPost.User, user);
            Assert.AreEqual(newPost.Topic, topic);
        }
开发者ID:kangjh0815,项目名称:test,代码行数:35,代码来源:PostServiceTests.cs


示例2: UserToMemberEditViewModel

 public static MemberEditViewModel UserToMemberEditViewModel(MembershipUser user)
 {
     var viewModel = new MemberEditViewModel
     {
         IsApproved = user.IsApproved,
         Id = user.Id,
         IsLockedOut = user.IsLockedOut,
         IsBanned = user.IsBanned,
         Roles = user.Roles.Select(x => x.RoleName).ToArray(),
         UserName = user.UserName,
         Age = user.Age,
         Comment = user.Comment,
         Email = user.Email,
         Facebook = user.Facebook,
         Location = user.Location,
         PasswordAnswer = user.PasswordAnswer,
         PasswordQuestion = user.PasswordQuestion,
         Signature = user.Signature,
         Twitter = user.Twitter,
         Website = user.Website,
         DisableEmailNotifications = (user.DisableEmailNotifications == true),
         DisablePosting = (user.DisablePosting == true),
         DisablePrivateMessages = (user.DisablePrivateMessages == true),
         DisableFileUploads = (user.DisableFileUploads == true),
         Avatar = user.Avatar
     };
     return viewModel;
 }
开发者ID:ivanchen52,项目名称:mvcforum,代码行数:28,代码来源:ViewModelMapping.cs


示例3: Rule

        public bool Rule(MembershipUser user, IMVCForumAPI api)
        {
            //Post is marked as the answer to a topic - give the post author a badge
            var usersSolutions = api.Post.GetSolutionsWrittenByMember(user.Id);

            return (usersSolutions.Count >= 1);
        }
开发者ID:StefanoPireddu,项目名称:mvcforum,代码行数:7,代码来源:BadgeServiceTests.cs


示例4: Rule

 public bool Rule(MembershipUser user)
 {
     // Get all down votes
     var voteService = DependencyResolver.Current.GetService<IVoteService>();
     var downVotes = voteService.GetAllVotesByUser(user.Id).Where(x => x.Amount < 1).ToList();
     return downVotes.Count() >= 10;
 }
开发者ID:Xamarui,项目名称:mvcforum,代码行数:7,代码来源:GrouchBadge.cs


示例5: GetUsersPrivateMessages

        public IPagedList<PrivateMessageListItem> GetUsersPrivateMessages(int pageIndex, int pageSize, MembershipUser user)
        {
            var query = _context.PrivateMessage
                .AsNoTracking()
                .Include(x => x.UserFrom)
                .Include(x => x.UserTo)
                .Where(x => (x.UserTo.Id == user.Id && x.IsSentMessage != true) || (x.UserFrom.Id == user.Id && x.IsSentMessage == true))
                .Select(x => new PrivateMessageListItem
                {
                    Date = x.DateSent,
                    User = (x.IsSentMessage == true ? x.UserTo : x.UserFrom),
                    HasUnreadMessages = (x.IsSentMessage != true && x.UserFrom.Id != user.Id && (x.IsRead == false))
                })
                .GroupBy(x => x.User.Id)
                .Select(x => x.OrderByDescending(d => d.Date).FirstOrDefault())
                .OrderByDescending(x => x.Date);

            var total = query.Count();

            var results = query
                            .Skip((pageIndex - 1) * pageSize)
                            .Take(pageSize)
                            .ToList();

            // Return a paged list
            return new PagedList<PrivateMessageListItem>(results, pageIndex, pageSize, total);
        }
开发者ID:huchao007,项目名称:mvcforum,代码行数:27,代码来源:PrivateMessageRepository.cs


示例6: GetUsersPrivateMessages

        //public IPagedList<PrivateMessage> GetPagedSentMessagesByUser(int pageIndex, int pageSize, MembershipUser user)
        //{
        //    var totalCount = _context.PrivateMessage
        //                        .Include(x => x.UserTo)
        //                        .Include(x => x.UserFrom)
        //                        .Count(x => x.UserFrom.Id == user.Id && x.IsSentMessage == true);

        //    // Get the topics using an efficient
        //    var results = _context.PrivateMessage
        //                        .Include(x => x.UserTo)
        //                        .Include(x => x.UserFrom)
        //                        .Where(x => x.UserFrom.Id == user.Id)
        //                        .Where(x => x.IsSentMessage == true)
        //                        .OrderByDescending(x => x.DateSent)
        //                        .Skip((pageIndex - 1) * pageSize)
        //                        .Take(pageSize)
        //                        .ToList();

        //    // Return a paged list
        //    return new PagedList<PrivateMessage>(results, pageIndex, pageSize, totalCount);
        //}

        //public IPagedList<PrivateMessage> GetPagedReceivedMessagesByUser(int pageIndex, int pageSize, MembershipUser user)
        //{


        //    var totalCount = _context.PrivateMessage
        //                        .Include(x => x.UserTo)
        //                        .Include(x => x.UserFrom)                                
        //                        .OrderByDescending(x => x.DateSent)
        //                        .Count(x => (x.UserTo.Id == user.Id || x.UserFrom.Id == user.Id) && x.IsSentMessage != true);

        //    var results = _context.PrivateMessage
        //                        .Include(x => x.UserTo)
        //                        .Include(x => x.UserFrom)
        //                        .OrderByDescending(x => x.DateSent)
        //                        .Where(x => (x.UserTo.Id == user.Id || x.UserFrom.Id == user.Id) && x.IsSentMessage != true)
        //                        .Skip((pageIndex - 1) * pageSize)
        //                        .Take(pageSize)
        //                        .ToList();


        //    // Return a paged list
        //    return new PagedList<PrivateMessage>(results, pageIndex, pageSize, totalCount);
        //}

        public IPagedList<PrivateMessageListItem> GetUsersPrivateMessages(int pageIndex, int pageSize, MembershipUser user)
        {
            //TODO - Need to rework this as it's not very efficient

            // Get all received pms
            var members = user.PrivateMessagesReceived.Where(x => x.IsSentMessage == true).OrderByDescending(x => x.DateSent).DistinctBy(x => x.UserFrom.Id).Select(x => new PrivateMessageListItem
            {
                Date = x.DateSent,
                User = x.UserFrom
            }).ToList();

            // Get all sent pms + ISSent
            var sentToMembers = user.PrivateMessagesSent.Where(x => x.IsSentMessage != true).OrderByDescending(x => x.DateSent).DistinctBy(x => x.UserTo.Id).Select(x => new PrivateMessageListItem
            {
                Date = x.DateSent,
                User = x.UserTo
            }).ToList();

            // Add lists
            members.AddRange(sentToMembers);

            // Get the full amount
            var uniqueMembers = members.OrderByDescending(x => x.Date).DistinctBy(x => x.User.Id).ToList();
            var uniqueMembersCount = uniqueMembers.Count;

            // Now distinct the lists again
            members = uniqueMembers.Skip((pageIndex - 1) * pageSize)
                        .Take(pageSize)
                        .ToList();

            // Return a paged list
            return new PagedList<PrivateMessageListItem>(members, pageIndex, pageSize, uniqueMembersCount);
        }
开发者ID:Xamarui,项目名称:mvcforum,代码行数:79,代码来源:PrivateMessageRepository.cs


示例7: Rule

        public bool Rule(MembershipUser user)
        {
            //Post is marked as the answer to a topic - give the post author a badge
            var postService = DependencyResolver.Current.GetService<IPostService>();
            var usersSolutions = postService.GetSolutionsByMember(user.Id);

            return (usersSolutions.Count >= 10);
        }
开发者ID:Xamarui,项目名称:mvcforum,代码行数:8,代码来源:Padawan.cs


示例8: AddNewPost

        /// <summary>
        /// Add a new post
        /// </summary>
        /// <param name="postContent"> </param>
        /// <param name="topic"> </param>
        /// <param name="user"></param>
        /// <param name="permissions"> </param>
        /// <returns>True if post added</returns>
        public Post AddNewPost(string postContent, Topic topic, MembershipUser user, out PermissionSet permissions)
        {
            // Get the permissions for the category that this topic is in
            permissions = _roleService.GetPermissions(topic.Category, UsersRole(user));

            // Check this users role has permission to create a post
            if (permissions[AppConstants.PermissionDenyAccess].IsTicked || permissions[AppConstants.PermissionReadOnly].IsTicked)
            {
                // Throw exception so Ajax caller picks it up
                throw new ApplicationException(_localizationService.GetResourceString("Errors.NoPermission"));
            }

            // Has permission so create the post
            var newPost = new Post
                               {
                                   PostContent = postContent,
                                   User = user,
                                   Topic = topic,
                                   IpAddress = StringUtils.GetUsersIpAddress(),
                                   DateCreated = DateTime.UtcNow,
                                   DateEdited = DateTime.UtcNow
                               };

            // Sort the search field out

            var category = topic.Category;
            if (category.ModeratePosts == true)
            {
                newPost.Pending = true;
            }

            var e = new PostMadeEventArgs { Post = newPost };
            EventManager.Instance.FireBeforePostMade(this, e);

            if (!e.Cancel)
            {
                // create the post
                Add(newPost);

                // Update the users points score and post count for posting
                _membershipUserPointsService.Add(new MembershipUserPoints
                                                     {
                                                         Points = _settingsService.GetSettings().PointsAddedPerPost,
                                                         User = user,
                                                         PointsFor = PointsFor.Post,
                                                         PointsForId = newPost.Id
                                                     });

                // add the last post to the topic
                topic.LastPost = newPost;

                EventManager.Instance.FireAfterPostMade(this, new PostMadeEventArgs { Post = newPost });

                return newPost;
            }

            return newPost;
        }
开发者ID:VerdantAutomation,项目名称:mvcforum,代码行数:66,代码来源:PostService.cs


示例9: Delete

 public void Delete(MembershipUser user, PointsFor type, Guid referenceId)
 {
     var mp =
         _context.MembershipUserPoints.Where(
             x => x.User.Id == user.Id && x.PointsFor == type && x.PointsForId == referenceId);
     var mpoints = new List<MembershipUserPoints>();
     mpoints.AddRange(mp);
     Delete(mpoints);
 }
开发者ID:huchao007,项目名称:mvcforum,代码行数:9,代码来源:MembershipUserPointsRepository.cs


示例10: Rule

 public bool Rule(MembershipUser user)
 {
     var lastPost = user.Posts.OrderByDescending(x => x.DateCreated).FirstOrDefault();
     if (lastPost != null && lastPost.PostContent.ToLower().Contains("umbraco"))
     {
         return true;
     }
     return false;
 }
开发者ID:dragon6776,项目名称:mvcforumdemo,代码行数:9,代码来源:PostMentionsUmbraco.cs


示例11: GetByUserAndTag

 public IList<TagNotification> GetByUserAndTag(MembershipUser user, TopicTag tag, bool addTracking = false)
 {
     var notifications = _context.TagNotification
        .Where(x => x.User.Id == user.Id && x.Tag.Id == tag.Id);
     if (addTracking)
     {
         return notifications.ToList();
     }
     return notifications.AsNoTracking().ToList();
 }
开发者ID:dragon6776,项目名称:mvcforumdemo,代码行数:10,代码来源:TagNotificationRepository.cs


示例12: Create

        public MembershipUser Create(string name)
        {
            var newUser = new MembershipUser
                              {
                                  UserName = name
                              };

            // Id is created by API
            return _api.Member.Create(newUser);
        }
开发者ID:kangjh0815,项目名称:test,代码行数:10,代码来源:APIExamples.cs


示例13: GetByUserAndCategory

 /// <summary>
 /// Return notifications for a specified user and category
 /// </summary>
 /// <param name="user"></param>
 /// <param name="category"></param>
 /// <param name="addTracking"></param>
 /// <returns></returns>
 public IList<CategoryNotification> GetByUserAndCategory(MembershipUser user, Category category, bool addTracking = false)
 {
     var notifications = _context.CategoryNotification
         .Where(x => x.Category.Id == category.Id && x.User.Id == user.Id);
     if (addTracking)
     {
         return notifications.ToList();
     }
     return notifications.AsNoTracking().ToList();
 }
开发者ID:ivanchen52,项目名称:mvcforum,代码行数:17,代码来源:CategoryNotificationService.cs


示例14: GetByUser

 public IEnumerable<MembershipUserPoints> GetByUser(MembershipUser user, bool removeTracking = true)
 {            
     var users = _context.MembershipUserPoints
             .Where(x => x.User.Id == user.Id);
     if (removeTracking)
     {
         return users.AsNoTracking();    
     }
     return users;
 }
开发者ID:huchao007,项目名称:mvcforum,代码行数:10,代码来源:MembershipUserPointsRepository.cs


示例15: MemberJoinedActivityAdd

        public void MemberJoinedActivityAdd()
        {
            const string guidStr = "515b7240-3be1-43d4-8846-c0b589cd1cd2";
            var activityRepository = Substitute.For<IActivityRepository>();
            IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService);
            var user = new MembershipUser { Id = new Guid(guidStr), UserName = "SpongeBob" };

            activityService.MemberJoined(user);

            activityRepository.Received().Add((Arg.Is<Activity>(x => x.Data == MemberJoinedActivity.KeyUserId + "=" + guidStr)));
        }
开发者ID:StefanoPireddu,项目名称:mvcforum,代码行数:11,代码来源:ActivityServiceTests.cs


示例16: Rule

        public bool Rule(MembershipUser user)
        {
            //Post is marked as the answer to a topic - give the post author a badge

            // Get all categories as we want to check all the members solutions, even across
            // categories that he no longer is allowed to access
            var cats = _categoryService.GetAll();
            var usersSolutions = _postService.GetSolutionsByMember(user.Id, cats);

            return (usersSolutions.Count >= 1);
        }
开发者ID:huchao007,项目名称:mvcforum,代码行数:11,代码来源:PosterMarkAsSolutionBadge.cs


示例17: BaseController

        //private readonly MembershipUser _loggedInUser;
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="loggingService"> </param>
        /// <param name="unitOfWorkManager"> </param>
        /// <param name="membershipService"></param>
        /// <param name="localizationService"> </param>
        /// <param name="roleService"> </param>
        /// <param name="settingsService"> </param>
        public BaseController(ILoggingService loggingService, IUnitOfWorkManager unitOfWorkManager, IMembershipService membershipService, ILocalizationService localizationService, IRoleService roleService, ISettingsService settingsService)
        {
            UnitOfWorkManager = unitOfWorkManager;
            MembershipService = membershipService;
            LocalizationService = localizationService;
            RoleService = roleService;
            SettingsService = settingsService;
            LoggingService = loggingService;

            LoggedOnReadOnlyUser = UserIsAuthenticated ? MembershipService.GetUser(Username, true) : null;
            UsersRole = LoggedOnReadOnlyUser == null ? RoleService.GetRole(AppConstants.GuestRoleName, true) : LoggedOnReadOnlyUser.Roles.FirstOrDefault();
        }
开发者ID:petemidge,项目名称:mvcforum,代码行数:22,代码来源:BaseController.cs


示例18: UserToSingleMemberListViewModel

 public static SingleMemberListViewModel UserToSingleMemberListViewModel(MembershipUser user)
 {
     var viewModel = new SingleMemberListViewModel
     {
         IsApproved = user.IsApproved,
         Id = user.Id,
         IsLockedOut = user.IsLockedOut,
         Roles = user.Roles.Select(x => x.RoleName).ToArray(),
         UserName = user.UserName
     };
     return viewModel;
 }
开发者ID:ivanchen52,项目名称:mvcforum,代码行数:12,代码来源:ViewModelMapping.cs


示例19: AddNewPost

        /// <summary>
        /// Add a new post
        /// </summary>
        /// <param name="postContent"> </param>
        /// <param name="topic"> </param>
        /// <param name="user"></param>
        /// <param name="permissions"> </param>
        /// <returns>True if post added</returns>
        public Post AddNewPost(string postContent, Topic topic, MembershipUser user, out PermissionSet permissions)
        {
            // Get the permissions for the category that this topic is in
            permissions = _roleService.GetPermissions(topic.Category, UsersRole(user));

            // Check this users role has permission to create a post
            if (permissions[AppConstants.PermissionDenyAccess].IsTicked || permissions[AppConstants.PermissionReadOnly].IsTicked)
            {
                // Throw exception so Ajax caller picks it up
                throw new ApplicationException(_localizationService.GetResourceString("Errors.NoPermission"));
            }

            // Has permission so create the post
            var newPost = new Post
                               {
                                   PostContent = postContent,
                                   User = user,
                                   Topic = topic,
                                   IpAddress = StringUtils.GetUsersIpAddress()
                               };

            newPost = SanitizePost(newPost);

            var e = new PostMadeEventArgs { Post = newPost, Api = _api };
            EventManager.Instance.FireBeforePostMade(this, e);

            if (!e.Cancel)
            {
                // create the post
                Add(newPost);

                // Update the users points score and post count for posting
                _membershipUserPointsService.Add(new MembershipUserPoints
                                                     {
                                                         Points = _settingsService.GetSettings().PointsAddedPerPost,
                                                         User = user
                                                     });

                // add the last post to the topic
                topic.LastPost = newPost;

                // Removed as its updated via the commit
                //_topicRepository.Update(topic);

                EventManager.Instance.FireAfterPostMade(this, new PostMadeEventArgs { Post = newPost, Api = _api });

                return newPost;
            }

            return newPost;
        }
开发者ID:kangjh0815,项目名称:test,代码行数:59,代码来源:PostService.cs


示例20: BadgeAwardedActivityAdd

        public void BadgeAwardedActivityAdd()
        {
            const string guidStrBadge = "515b7240-3be1-43d4-8846-c0b589cd1cd2";
            const string guidStrUser = "0c462b02-a991-48d8-8435-92f04e666675";

            var activityRepository = Substitute.For<IActivityRepository>();
            IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService);
            var user = new MembershipUser { Id = new Guid(guidStrUser), UserName = "SpongeBob" };
            var badge = new Badge { Id = new Guid(guidStrBadge) };

            activityService.BadgeAwarded(badge, user, DateTime.UtcNow);

            activityRepository.Received().Add((Arg.Is<Activity>(x => x.Data == BadgeActivity.KeyBadgeId + "=" + guidStrBadge + "," + BadgeActivity.KeyUserId + "=" + guidStrUser)));
        }
开发者ID:kangjh0815,项目名称:test,代码行数:14,代码来源:ActivityServiceTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# DomainModel.Topic类代码示例发布时间:2022-05-26
下一篇:
C# DomainModel.MembershipRole类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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