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


C# IUserRepository.GetAll方法代码示例

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


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

示例1: UserPresenter

        public UserPresenter(IUserUserControl ctrl)
        {
            view = ctrl;
            usersRepository = new UserRepository(new MyContext());
            usersList = new List<User>();
            usersList = usersRepository.GetAll().ToList();
            showingCount = usersList.Count;

            view.DrawUsersTable(usersList);
        }
开发者ID:vbre,项目名称:CS_2015_Winter,代码行数:10,代码来源:UserPresenter.cs

示例2: TransactionPresenter

        public TransactionPresenter(ITransactionUserControl ctrl)
        {
            view = ctrl;
            transactionsRepository = new TransactionRepository();
            transactionsList = new List<Transaction>();
            transactionsList = transactionsRepository.GetAll().ToList();
            usersRepository = new UserRepository(new MyContext());
            usersList = usersRepository.GetAll().ToList();
            showingCount = transactionsList.Count;

            view.DrawTransactionsTable(transactionsList);
        }
开发者ID:vbre,项目名称:CS_2015_Winter,代码行数:12,代码来源:TransactionPresenter.cs

示例3: AdminModule

        public AdminModule(IdeastrikeContext dbContext, ISettingsRepository settings, IUserRepository users)
            : base("/admin")
        {
            this.RequiresAuthentication();

            Get["/"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", settings.Title));
                m.Name = settings.Name;
                m.WelcomeMessage = settings.WelcomeMessage;
                m.HomePage = settings.HomePage;
                m.GAnalyticsKey = settings.GAnalyticsKey;
                return View["Admin/Index", m];
            };

            Get["/users"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", settings.Title));
                m.Name = settings.Name;
                m.WelcomeMessage = settings.WelcomeMessage;
                m.HomePage = settings.HomePage;
                m.GAnalyticsKey = settings.GAnalyticsKey;
                m.Users = users.GetAll();
                return View["Admin/Users", m];
            };

            Get["/moderation"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", settings.Title));
                m.Name = settings.Name;
                m.WelcomeMessage = settings.WelcomeMessage;
                m.HomePage = settings.HomePage;
                m.GAnalyticsKey = settings.GAnalyticsKey;
                return View["Admin/Moderation", m];
            };

            Get["/settings"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", settings.Title));
                m.Name = settings.Name;
                m.WelcomeMessage = settings.WelcomeMessage;
                m.HomePage = settings.HomePage;
                m.GAnalyticsKey = settings.GAnalyticsKey;

                return View["Admin/Settings", m];
            };

            Post["/settings"] = _ =>
            {
                settings.WelcomeMessage = Request.Form.welcomemessage;
                settings.Title = Request.Form.title;
                settings.Name = Request.Form.yourname;
                settings.HomePage = Request.Form.homepage;
                settings.GAnalyticsKey = Request.Form.analyticskey;
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    var y = ex.Message;
                }

                return Response.AsRedirect("/admin/settings");
            };

            Get["/search"] = _ => "";
            Get["/forums"] = _ => "";
            Get["/forum/{forumId}"] = _ => "";
        }
开发者ID:janode,项目名称:Ideastrike,代码行数:70,代码来源:AdminModule.cs

示例4: AdminModule

        public AdminModule(IdeastrikeContext dbContext, Settings settings, IUserRepository users, IIdeaRepository ideas, IActivityRepository activities)
            : base("/admin")
        {
            this.RequiresAuthentication();
            this.RequiresValidatedClaims(c => c.Contains("admin"));

            _settings = settings;
            _users = users;
            _ideas = ideas;
            _activities = activities;

            Get["/"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", (string)_settings.SiteTitle));
                m.Name = _settings.Name;
                m.WelcomeMessage = _settings.WelcomeMessage;
                m.HomePage = _settings.HomePage;
                m.GAnalyticsKey = _settings.GAnalyticsKey;
                return View["Admin/Index", m];
            };

            Get["/users"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", (string)_settings.SiteTitle));
                m.Name = _settings.Name;
                m.WelcomeMessage = _settings.WelcomeMessage;
                m.HomePage = _settings.HomePage;
                m.GAnalyticsKey = _settings.GAnalyticsKey;
                m.Users = users.GetAll();
                return View["Admin/Users", m];
            };

            Get["/moderation"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", (string)_settings.SiteTitle));
                m.Name = _settings.Name;
                m.WelcomeMessage = _settings.WelcomeMessage;
                m.HomePage = _settings.HomePage;
                m.GAnalyticsKey = _settings.GAnalyticsKey;
                return View["Admin/Moderation", m];
            };

            Get["/settings"] = _ =>
            {
                var m = Context.Model(string.Format("Admin - {0}", (string)_settings.SiteTitle));
                m.Name = _settings.Name;
                m.SiteTitle = _settings.SiteTitle;
                m.WelcomeMessage = _settings.WelcomeMessage;
                m.HomePage = _settings.HomePage;
                m.GAnalyticsKey = _settings.GAnalyticsKey;
                m.MaxThumbnailWidth = _settings.MaxThumbnailWidth;

                return View["Admin/Settings", m];
            };

            Post["/settings"] = _ =>
            {
                _settings.WelcomeMessage = Request.Form.welcomemessage;
                _settings.SiteTitle = Request.Form.sitetitle;
                _settings.Name = Request.Form.yourname;
                _settings.HomePage = Request.Form.homepage;
                _settings.GAnalyticsKey = Request.Form.analyticskey;
                _settings.MaxThumbnailWidth = Request.Form.maxthumbnailwidth;

                return Response.AsRedirect("/admin/settings");
            };

            Get["/search"] = _ => "";
            Get["/forums"] = _ => "";
            Get["/forum/{forumId}"] = _ => "";

            Get["/uservoice"] = _ => View["Admin/Uservoice", Context.Model("Admin")];
            Post["/uservoice"] = _ =>
            {
                var client = new WebClient();
                var suggestions = GetSuggestions(client, Request.Form.channel, Request.Form.forumid, Request.Form.apikey, Request.Form.trusted);

                foreach (var s in suggestions)
                {
                    string title = s.title;

                    //If the idea exists, skip it
                    if (ideas.FindBy(i => i.Title == title).Any())
                        continue;

                    string date = s.created_at;
                    var idea = new Idea
                    {
                        Title = title,
                        Description = s.text,
                        Time = DateTime.Parse(date.Substring(0, date.Length - 5)),
                    };

                    string status = string.Empty;
                    switch ((string)s.state)
                    {
                        case "approved":
                            status = "Active";
                            break;
                        case "closed" :
//.........这里部分代码省略.........
开发者ID:Code52,项目名称:Ideastrike,代码行数:101,代码来源:AdminModule.cs

示例5: LoginModule

        public LoginModule(IUserRepository userRepository)
        {
            _user = userRepository;

            Post["/login/token"] = x =>
            {
                if (string.IsNullOrWhiteSpace(Request.Form.token))
                    return
                        View["Login/Error",
                            new
                                {
                                    Title = "Login Error",
                                    Message = "Bad response from login provider - could not find login token."
                                }];

                var response = new WebClient().DownloadString(string.Format("https://rpxnow.com/api/v2/auth_info?apiKey={0}&token={1}",apikey, Request.Form.token));

                if (string.IsNullOrWhiteSpace(response))
                    return
                        View["Login/Error",
                            new
                                {
                                    Title = "Login Error",
                                    Message = "Bad response from login provider - could not find user."
                                }];

                var j = JsonConvert.DeserializeObject<dynamic>(response);

                if (j.stat.ToString() != "ok")
                    return
                        View["Login/Error",
                            new
                                {
                                    Title = "Login Error",
                                    Message = "Bad response from login provider."
                                }];

                var userIdentity = j.profile.identifier.ToString();
                var username = j.profile.preferredUsername.ToString();
                string email = string.Empty;
                if (j.profile.email != null)
                    email = j.profile.email.ToString();
                var user = _user.GetUserFromUserIdentity(userIdentity);

                if (user == null)
                {
                    var u = new User
                                {
                                    Id = Guid.NewGuid(),
                                    Identity = userIdentity,
                                    UserName = (!string.IsNullOrEmpty(username)) ? username : "New User " + _user.GetAll().Count(),
                                    Email = (!string.IsNullOrEmpty(email)) ? email : "[email protected]",
                                    Github = (!string.IsNullOrEmpty(username)) ? username : "",
                                    IsActive = true,
                                };

                    if (!_user.GetAll().Any())
                        _user.AddRole(u, "Admin");

                    if (j.profile.photo != null)
                        u.AvatarUrl = j.profile.photo.ToString();

                    _user.Add(u);
                    return this.LoginAndRedirect(u.Id, DateTime.Now.AddDays(1), "/profile/edit");
                }

                return ModuleExtensions.Login(this, user.Id, DateTime.Now.AddDays(1), "/");
            };

            Get["/logout/"] = parameters => this.LogoutAndRedirect("/");
        }
开发者ID:caleb-vear,项目名称:Ideastrike,代码行数:71,代码来源:LoginModule.cs

示例6: ValidateRegistration

        public static bool ValidateRegistration(string userName, string password, string confirmPassword, 
            ModelStateDictionary modelState, IMembershipService membershipService,
            IUserRepository userRepository)
        {
            if (userRepository.GetAll().Any(u => u.Login.ToUpper() == userName.ToUpper()))
            {
                modelState.AddModelError("username", "Пользователь с таким именем уже присутствует.");
            }

            if (String.IsNullOrEmpty(userName))
            {
                modelState.AddModelError("username", "Нужно указать имя пользователя.");
            }

            if (userName.Length < 2 || userName.Length > 25)
            {
                modelState.AddModelError("username", "Имя должно быть не короче 2 и не длиннее 25 символов.");
            }

            if (userName.StartsWith(" ") || userName.EndsWith(" "))
            {
                modelState.AddModelError("username", "Имя не может быть пустым, а также начинаться или заканчиваться пробелами.");
            }

            /*if (String.IsNullOrEmpty(email))
            {
                ModelState.AddModelError("email", "You must specify an email address.");
            }*/

            if (String.IsNullOrEmpty(password) || password.Length < membershipService.MinPasswordLength)
            {
                modelState.AddModelError("password",
                    String.Format(CultureInfo.CurrentCulture,
                         "Новый пароль должен содержать не менее {0} символов.",
                         membershipService.MinPasswordLength));
            }
            if (!String.Equals(password, confirmPassword, StringComparison.Ordinal))
            {
                modelState.AddModelError("_FORM", "Новый пароль не совпадает с подтверждением пароля.");
            }
            return modelState.IsValid;
        }
开发者ID:BrandFox,项目名称:beavers-encounter,代码行数:42,代码来源:AccountController.cs


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