private void AplyDtoToEntity(Data.Models.Sportsman sportsman, SportsmanDto sportsmanDto) { sportsman.Name = sportsmanDto.Name; sportsman.Age = sportsmanDto.Age; sportsman.Experience = sportsmanDto.Experience; sportsman.TeamId = sportsmanDto.TeamId; }
public async Task Delete(int id) { Data.Models.Sportsman sportsman = _sportsmanDbContext.Sportsmans.Find(id); _sportsmanDbContext.Sportsmans.Remove(sportsman); await _sportsmanDbContext.SaveChangesAsync(); }
public async Task <int> Update(SportsmanDto sportsmanDto) { Data.Models.Sportsman sportsman = _sportsmanDbContext.Sportsmans.Find(sportsmanDto.Id); AplyDtoToEntity(sportsman, sportsmanDto); await _sportsmanDbContext.SaveChangesAsync(); return(sportsman.Id); }
public async Task <int> Create(SportsmanDto sportsmanDto) { Data.Models.Sportsman sportsman = new Data.Models.Sportsman(); AplyDtoToEntity(sportsman, sportsmanDto); _sportsmanDbContext.Sportsmans.Add(sportsman); await _sportsmanDbContext.SaveChangesAsync(); return(sportsman.Id); }