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

C# Data.BonoboGitServerContext类代码示例

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

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



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

示例1: Create

        public bool Create(RepositoryModel model)
        {
            if (model == null) throw new ArgumentException("model");
            if (model.Name == null) throw new ArgumentException("name");

            using (var database = new BonoboGitServerContext())
            {
                var repository = new Repository
                {
                    Name = model.Name,
                    Logo = model.Logo,
                    Group = model.Group,
                    Description = model.Description,
                    Anonymous = model.AnonymousAccess,
                    AuditPushUser = model.AuditPushUser,
                };
                database.Repositories.Add(repository);
                AddMembers(model.Users, model.Administrators, model.Teams, repository, database);
                try
                {
                    database.SaveChanges();
                }
                catch (UpdateException)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:ywg663,项目名称:Bonobo-Git-Server,代码行数:30,代码来源:EFRepositoryRepository.cs


示例2: GetAllRepositories

        public IList<RepositoryModel> GetAllRepositories()
        {
            using (var db = new BonoboGitServerContext())
            {
                var dbrepos = db.Repositories.Select(repo => new
                {
                    Name = repo.Name,
                    Group = repo.Group,
                    Description = repo.Description,
                    AnonymousAccess = repo.Anonymous,
                    Users = repo.Users.Select(i => i.Username),
                    Teams = repo.Teams.Select(i => i.Name),
                    Administrators = repo.Administrators.Select(i => i.Username),
                    AuditPushUser = repo.AuditPushUser,
                    Logo = repo.Logo
                }).ToList();

                return dbrepos.Select(repo => new RepositoryModel
                {
                    Name = repo.Name,
                    Group = repo.Group,
                    Description = repo.Description,
                    AnonymousAccess = repo.AnonymousAccess,
                    Users = repo.Users.ToArray(),
                    Teams = repo.Teams.ToArray(),
                    Administrators = repo.Administrators.ToArray(),
                    AuditPushUser = repo.AuditPushUser,
                    Logo = repo.Logo
                }).ToList();
            }
        }
开发者ID:ywg663,项目名称:Bonobo-Git-Server,代码行数:31,代码来源:EFRepositoryRepository.cs


示例3: Create

        public bool Create(TeamModel model)
        {
            if (model == null) throw new ArgumentException("team");
            if (model.Name == null) throw new ArgumentException("name");

            using (var database = new BonoboGitServerContext())
            {
                var team = new Team
                {
                    Name = model.Name,
                    Description = model.Description
                };
                database.Teams.Add(team);
                if (model.Members != null)
                {
                    AddMembers(model.Members, team, database);
                }
                try
                {
                    database.SaveChanges();
                }
                catch (UpdateException)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:ywg663,项目名称:Bonobo-Git-Server,代码行数:29,代码来源:EFTeamRepository.cs


示例4: CreateUser

        public bool CreateUser(string username, string password, string name, string surname, string email)
        {
            if (String.IsNullOrEmpty(username)) throw new ArgumentException("Value cannot be null or empty.", "userName");
            if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
            if (String.IsNullOrEmpty(name)) throw new ArgumentException("Value cannot be null or empty.", "name");
            if (String.IsNullOrEmpty(surname)) throw new ArgumentException("Value cannot be null or empty.", "surname");
            if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");

            username = username.ToLowerInvariant();
            using (var database = new BonoboGitServerContext())
            {
                var user = new User
                {
                    Username = username,
                    Password = EncryptPassword(password),
                    Name = name,
                    Surname = surname,
                    Email = email,
                };
                database.Users.Add(user);
                try
                {
                    database.SaveChanges();
                }
                catch (UpdateException)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:khorvat,项目名称:Bonobo-Git-Server,代码行数:32,代码来源:EFMembershipService.cs


示例5: GetAllRoles

 public override string[] GetAllRoles()
 {
     using (var database = new BonoboGitServerContext())
     {
         return database.Roles.Select(i => i.Name).ToArray();
     }
 }
开发者ID:hammadrauf,项目名称:Bonobo-Git-Server,代码行数:7,代码来源:EFRoleProvider.cs


示例6: AllowsAnonymous

 public bool AllowsAnonymous(string project)
 {
     using (var database = new BonoboGitServerContext())
     {
         var repo = database.Repositories.FirstOrDefault(i => i.Name == project);
         return (repo != null && repo.Anonymous);
     }
 }
开发者ID:TheBlueSky,项目名称:Bonobo-Git-Server,代码行数:8,代码来源:EFRepositoryPermissionService.cs


示例7: AllowsAnonymous

 public bool AllowsAnonymous(string project)
 {
     using (var database = new BonoboGitServerContext())
     {
         var isAllowsAnonymous = database.Repositories.Any(repo => repo.Name == project && repo.Anonymous);
         return isAllowsAnonymous;
     }
 }
开发者ID:einer20,项目名称:Bonobo-Git-Server,代码行数:8,代码来源:EFRepositoryPermissionService.cs


示例8: GetRepository

        public RepositoryModel GetRepository(string name)
        {
            if (name == null) throw new ArgumentException("name");

            using (var db = new BonoboGitServerContext())
            {
                return ConvertToModel(db.Repositories.FirstOrDefault(i => i.Name == name));
            }
        }
开发者ID:Webmine,项目名称:Bonobo-Git-Server,代码行数:9,代码来源:EFRepositoryRepository.cs


示例9: CreateRole

 public override void CreateRole(string roleName)
 {
     using (var database = new BonoboGitServerContext())
     {
         database.Roles.Add(new Role
         {
             Name = roleName,
         });
     }
 }
开发者ID:hammadrauf,项目名称:Bonobo-Git-Server,代码行数:10,代码来源:EFRoleProvider.cs


示例10: FindUsersInRole

 public override string[] FindUsersInRole(string roleName, string usernameToMatch)
 {
     using (var database = new BonoboGitServerContext())
     {
         var users = database.Users
             .Where(us => us.Username.Contains(usernameToMatch) && us.Roles.Any(role => role.Name == roleName))
             .Select(us => us.Username)
             .ToArray();
         return users;
     }
 }
开发者ID:hammadrauf,项目名称:Bonobo-Git-Server,代码行数:11,代码来源:EFRoleProvider.cs


示例11: GetAllRepositories

 public IList<Models.RepositoryModel> GetAllRepositories()
 {
     using (var db = new BonoboGitServerContext())
     {
         var result = new List<RepositoryModel>();
         foreach (var item in db.Repositories)
         {
             result.Add(ConvertToModel(item));
         }
         return result;
     }
 }
开发者ID:khorvat,项目名称:Bonobo-Git-Server,代码行数:12,代码来源:EFRepositoryRepository.cs


示例12: GetAllUsers

 public IList<UserModel> GetAllUsers()
 {
     using (var db = new BonoboGitServerContext())
     {
         return db.Users.Include("Roles").ToList().Select(item => new UserModel
         {
             Username = item.Username,
             Name = item.Name,
             Surname = item.Surname,
             Email = item.Email,
             Roles = item.Roles.Select(i => i.Name).ToArray(),
         }).ToList();
     }
 }
开发者ID:kogot,项目名称:Bonobo-Git-Server,代码行数:14,代码来源:EFMembershipService.cs


示例13: IsRepositoryAdministrator

        public bool IsRepositoryAdministrator(string username, string project)
        {
            using (var database = new BonoboGitServerContext())
            {
                username = username.ToLowerInvariant();

                var isRepoAdmin =
                    database.Users.Where(us => us.Username == username)
                        .Any(
                            us =>
                                (us.Roles.Any(role => role.Name == Definitions.Roles.Administrator) ||
                                 us.AdministratedRepositories.Any(ar => ar.Name == project)));
                return isRepoAdmin;
            }
        }
开发者ID:einer20,项目名称:Bonobo-Git-Server,代码行数:15,代码来源:EFRepositoryPermissionService.cs


示例14: GetTeam

        public TeamModel GetTeam(string name)
        {
            if (name == null) throw new ArgumentException("name");

            using (var db = new BonoboGitServerContext())
            {
                var team = db.Teams.FirstOrDefault(i => i.Name == name);
                return team == null ? null : new TeamModel
                {
                    Name = team.Name,
                    Description = team.Description,
                    Members = team.Users.Select(m => m.Username).ToArray(),
                };
            }
        }
开发者ID:ikarstein,项目名称:Bonobo-Git-Server,代码行数:15,代码来源:EFTeamRepository.cs


示例15: Delete

        public void Delete(string name)
        {
            if (name == null) throw new ArgumentException("name");

            using (var db = new BonoboGitServerContext())
            {
                var team = db.Teams.FirstOrDefault(i => i.Name == name);
                if (team != null)
                {
                    team.Repositories.Clear();
                    team.Users.Clear();
                    db.Teams.Remove(team);
                    db.SaveChanges();
                }
            }
        }
开发者ID:ywg663,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:EFTeamRepository.cs


示例16: IsRepositoryAdministrator

 public bool IsRepositoryAdministrator(string username, string project)
 {
     using (var database = new BonoboGitServerContext())
     {
         var user = database.Users.FirstOrDefault(i => i.Username == username);
         if (user != null)
         {
             if (user.Roles.FirstOrDefault(i => i.Name == Definitions.Roles.Administrator) != null
              || user.AdministratedRepositories.FirstOrDefault(i => i.Name == project) != null)
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:TheBlueSky,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:EFRepositoryPermissionService.cs


示例17: DeleteUser

 public void DeleteUser(string username)
 {
     using (var database = new BonoboGitServerContext())
     {
         var user = database.Users.FirstOrDefault(i => i.Username == username);
         if (user != null)
         {
             user.AdministratedRepositories.Clear();
             user.Roles.Clear();
             user.Repositories.Clear();
             user.Teams.Clear();
             database.Users.Remove(user);
             database.SaveChanges();
         }
     }
 }
开发者ID:TheBlueSky,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:EFMembershipService.cs


示例18: FindUsersInRole

 public override string[] FindUsersInRole(string roleName, string usernameToMatch)
 {
     var result = new HashSet<string>();
     using (var database = new BonoboGitServerContext())
     {
         var matchingRoles = database.Roles.Where(i => i.Name == roleName && i.Users.Where(user => user.Username.Contains(usernameToMatch)).Count() > 0);
         var usernames = matchingRoles.Select(i => i.Users.Select(u => u.Username));
         foreach (var roleUsernames in usernames)
         {
             foreach (var username in roleUsernames)
             {
                 result.Add(username);
             }
         }
     }
     return result.ToArray();
 }
开发者ID:TheBlueSky,项目名称:Bonobo-Git-Server,代码行数:17,代码来源:EFRoleProvider.cs


示例19: Delete

        public void Delete(string name)
        {
            if (name == null) throw new ArgumentException("name");

            using (var db = new BonoboGitServerContext())
            {
                var repo = db.Repositories.FirstOrDefault(i => i.Name == name);
                if (repo != null)
                {
                    repo.Administrators.Clear();
                    repo.Users.Clear();
                    repo.Teams.Clear();
                    db.Repositories.Remove(repo);
                    db.SaveChanges();
                }
            }
        }
开发者ID:ywg663,项目名称:Bonobo-Git-Server,代码行数:17,代码来源:EFRepositoryRepository.cs


示例20: AddUsersToRoles

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            using (var database = new BonoboGitServerContext())
            {
                var roles = database.Roles.Where(i => roleNames.Contains(i.Name));
                var users = database.Users.Where(i => usernames.Contains(i.Username));

                foreach (var role in roles)
                {
                    foreach (var user in users)
                    {
                        role.Users.Add(user);
                    }
                }

                database.SaveChanges();
            }
        }
开发者ID:TheBlueSky,项目名称:Bonobo-Git-Server,代码行数:18,代码来源:EFRoleProvider.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Models.RepositoryDetailModel类代码示例发布时间:2022-05-24
下一篇:
C# BoletoNet.Cedente类代码示例发布时间: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