public async Task <bool> Update(int id, HandicapsDto data) { var handicaps = _mapper.Map <HandicapsDto, Handicaps>(data); bool result = _repo.HandicapsRepository.Update(id, handicaps); await _repo.SaveAsync(); return(result); }
public async Task <bool> Insert(HandicapsDto data) { var handicaps = _mapper.Map <HandicapsDto, Handicaps>(data); bool result = _repo.HandicapsRepository.Insert(handicaps); await _repo.SaveAsync(); return(result); }
public async Task <IActionResult> Post([FromBody] HandicapsDto data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _handicapService.Insert(data); if (result == true) { return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] HandicapsDto data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != data.Id) { return(BadRequest()); } var result = await _handicapService.Update(id, data); if (result == true) { return(Ok()); } return(BadRequest()); }