public static Brand ToBrand(this BrandToPostDto brand) { if (brand == null) { return(null); } return(new Brand { Title = brand.Title, YearFounded = brand.YearFounded, Description = brand.Description }); }
public async Task <ActionResult <BrandDto> > CreateBrandAsync(BrandToPostDto brandDto) { var created = await _brandRepository.CreateBrandAsync(brandDto.ToBrand()); return(CreatedAtAction(nameof(GetBrandAsync), new { id = created.Id }, created.ToBrandDto())); }