public async Task <ActionResult <BrandViewModel> > PostAsync([FromBody] CreateUpdateBrandViewModel pe) { _logger.LogDebug("Post {0}", pe.Brand); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _repository.CreateBrandAsync(pe.Brand); if (!result) { return(BadRequest(new ProblemDetails() { Detail = result.Message })); } return(CreatedAtRoute("Brand" + nameof(GetAsync), new { id = result.Data.BrandId }, _mapper.Map <BrandViewModel>(result.Data))); }
public async Task <ActionResult <BrandViewModel> > PutAsync(int id, CreateUpdateBrandViewModel pe) { _logger.LogDebug("Put {0} {1}", id, pe.Brand); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _repository.UpdateBrandAsync(id, pe.Brand); if (!result) { return(BadRequest(new ProblemDetails() { Detail = result.Message })); } return(Ok(_mapper.Map <BrandViewModel>(result.Data))); }