Example #1
0
        public IHttpActionResult Postteams(TeamDTO teamdto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TeamManager mngr = new TeamManager();
            var         team = mngr.CreateTeam(teamdto.TeamName, teamdto.Teamlead_id);

            db.teams.Add(team);

            var teamleadTeam = mngr.AddUserTeam(team.id, team.teamlead_id);

            db.user_teams.Add(teamleadTeam);

            foreach (int id in teamdto.Users)
            {
                var userTeam = mngr.AddUserTeam(team.id, id);
                db.user_teams.Add(userTeam);
            }

            db.SaveChanges();
            return(Ok());
            ///return CreatedAtRoute("DefaultApi", new { id = teams.id }, teams);
        }