public async Task <ActionResult> EditNationalCompetitions(int id, NationalCompetitionDto competitionDto) { var check = await _competitionLogic.Edit(id, competitionDto); if (!check) { return(BadRequest()); } return(Ok()); }
public async Task <ActionResult> AddNationalCompetitions(NationalCompetitionDto competitionDto) { var check = await _competitionLogic.Add(competitionDto); if (!check) { return(BadRequest()); } return(Ok()); }
public async Task <bool> Edit(int id, NationalCompetitionDto competitionDto) { if (string.IsNullOrWhiteSpace(competitionDto.Name)) { return(false); } var competition = await _context.NationalCompetitions.FindAsync(id); if (competition == null) { return(false); } competition.Name = competitionDto.Name; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> Add(NationalCompetitionDto competitionDto) { if (string.IsNullOrWhiteSpace(competitionDto.Name)) { return(false); } var country = await _context.Countries.FindAsync(competitionDto.CountryId); if (country == null) { return(false); } var competition = new NationalCompetition { Name = competitionDto.Name, Country = country, }; _context.NationalCompetitions.Add(competition); await _context.SaveChangesAsync(); return(true); }