public async Task <IActionResult> CreateFootballer(FootballerPostDto footballerToAdd) { try { var guid = await footballerRepository.addFootballer(footballerToAdd); return(guid == Guid.Empty ? (IActionResult)StatusCode(500) : Ok(guid)); } catch (Exception e) { return(StatusCode(500)); } }
public async Task <Guid> addFootballer(FootballerPostDto FootballerPostDto) { Footballer footballer = new Footballer() { FootballerID = Guid.NewGuid(), FirstName = FootballerPostDto.FirstName, LastName = FootballerPostDto.LastName, ImgPath = FootballerPostDto.ImgPath }; await footballerContext.Footballers.AddAsync(footballer); await saveAll(); return(footballer.FootballerID); }