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


C# Data.BonoboGitServerContext类代码示例

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


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


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