public async Task <IActionResult> AddBeerType([FromBody] SaveBeerTypeDto beerTypeDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var beerType = _mapper.Map <SaveBeerTypeDto, BeerType>(beerTypeDto); if (!await _beerTypeService.AddBeerType(beerType)) { return(BadRequest("Wystąpił problem podczas dodawania typu piwa")); } return(Ok(beerTypeDto)); }
public async Task <IActionResult> UpdateBeerType(int id, [FromBody] SaveBeerTypeDto beerTypeDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var beerType = await _beerTypeService.GetBeerType(id); if (beerType == null) { return(NotFound()); } var mappedBeerType = _mapper.Map(beerTypeDto, beerType); if (!await _beerTypeService.UpdateBeerType(id, mappedBeerType)) { return(BadRequest("Wystąpił problem podczas modyfikacji typu piwa")); } return(Ok()); }