public void Post(TeamDTO value)
        {
            Team model = new Team()
            {
                Team_name    = value.Team_name,
                RealeaseYear = value.RealeaseYear,
                Image        = value.Image
            };

            ITeamRepository.Create(model);


            if (value.Employees != null)
            {
                foreach (EmployeeDTO employee in value.Employees)
                {
                    Employee newEmployee = new Employee()
                    {
                        TeamId      = model.Id,
                        First_name  = employee.First_name,
                        Second_name = employee.Second_name,
                        Function    = employee.Function,
                        Age         = employee.Age
                    };
                    IEmployeeRepository.Create(newEmployee);
                }
            }


            if (value.ComponentsId != null)
            {
                for (int i = 0; i < value.ComponentsId.Count; i++)
                {
                    TeamComponent newTeamComponent = new TeamComponent()
                    {
                        ComponentId = value.ComponentsId[i],
                        TeamId      = model.Id
                    };
                    ITeamComponentRepository.Create(newTeamComponent);
                }
            }

            if (value.RacesId != null)
            {
                for (int i = 0; i < value.RacesId.Count; i++)
                {
                    TeamRace newTeamRace = new TeamRace()
                    {
                        TeamId = model.Id,
                        RaceId = value.RacesId[i]
                    };
                    ITeamRaceRepository.Create(newTeamRace);
                }
            }
        }
Example #2
0
        public TeamComponent Post(TeamComponentDTO value)
        {
            TeamComponent model = new TeamComponent()
            {
                TeamId      = value.Id_team,
                ComponentId = value.Id_component
            };

            return(ITeamComponentRepository.Create(model));
        }