Пример #1
0
 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;
 }
Пример #2
0
        public async Task Delete(int id)
        {
            Data.Models.Sportsman sportsman = _sportsmanDbContext.Sportsmans.Find(id);

            _sportsmanDbContext.Sportsmans.Remove(sportsman);
            await _sportsmanDbContext.SaveChangesAsync();
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }