Ejemplo n.º 1
0
        public async Task <ActionResult <bool> > removeTeamFromSchool(TeamSchoolDto teamSchoolDto)
        {
            try
            {
                var teamx = await _teamRepo.GetTeam(teamSchoolDto.teamid);

                var schoolx = await _schoolRepo.GetSchoolWithID(teamSchoolDto.schoolid);

                schoolx.Teams.Remove(teamx);

                return(await _teamRepo.SaveAll());
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "db no good"));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <SchoolDto> > addTeamToSchool(TeamSchoolDto teamSchoolDto)
        {
            try
            {
                var teamx = await _teamRepo.GetTeam(teamSchoolDto.teamid);

                var schoolx = await _schoolRepo.GetSchoolWithID(teamSchoolDto.schoolid);

                schoolx.Teams.Add(teamx);
                var result = await _teamRepo.SaveAll();

                var schoolToReturn =
                    _mapper.Map <SchoolDto>(schoolx);
                return(Ok(schoolToReturn));
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "db no good"));
            }
        }