public async Task <IActionResult> CreateTouristGroup(TouristGroupDTO touristGroupDto) { var touristGroup = _mapper.Map <TouristGroupDTO, TouristGroup>(touristGroupDto); await _repository.Add(touristGroup); return(CreatedAtAction(nameof(GetTouristGroup), new { id = touristGroup.TouristGroupId }, touristGroup)); }
public async Task <IActionResult> UpdateTouristGroup(int id, TouristGroupDTO touristGroupDto) { if (id != touristGroupDto.TouristGroupId) { return(BadRequest()); } try { var touristGroup = _mapper.Map <TouristGroupDTO, TouristGroup>(touristGroupDto); await _repository.Update(id, touristGroup); } catch (DbUpdateConcurrencyException) { if (!await TouristGroupExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }