Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 private void AddMembers(IEnumerable<string> members, Team team, BonoboGitServerContext database)
 {
     var users = database.Users.Where(i => members.Contains(i.Username));
     foreach (var item in users)
     {
         team.Users.Add(item);
     }
 }