public async Task <IActionResult> Get(int id)
        {
            BrandDto brandDto = await _brandService.GetBrand(id);

            if (brandDto == null)
            {
                return(NotFound($"No such brand with id: {id}"));
            }
            BrandWebModel brandModel = _mapper.Map <BrandWebModel>(brandDto);

            return(Ok(brandModel));
        }
        public async Task <IActionResult> Post([FromBody] BrandCreateModel brandCreateModel)
        {
            if (await _brandService.BrandExist(brandCreateModel.Title))
            {
                return(Conflict("Such brand already exists"));
            }
            BrandDto brandDto        = _mapper.Map <BrandDto>(brandCreateModel);
            BrandDto createdBrandDto = await _brandService.CreateBrand(brandDto);

            BrandWebModel brandModel = _mapper.Map <BrandWebModel>(createdBrandDto);

            return(CreatedAtAction(nameof(Get), new { id = brandModel.BrandId }, brandModel));
        }
        public async Task <IActionResult> Update([FromBody] BrandUpdateModel brandUpdateModel)
        {
            BrandDto brandFromDb = await _brandService.GetBrand(brandUpdateModel.BrandId);

            if (brandFromDb == null)
            {
                return(NotFound("No such brand"));
            }

            BrandDto brandUpdateDto = _mapper.Map <BrandDto>(brandUpdateModel);

            if (await _brandService.UpdatedBrandExists(brandUpdateDto))
            {
                return(Conflict("This brand already exists"));
            }

            BrandDto updatedBrandDto = await _brandService.UpdateBrand(brandUpdateDto, brandUpdateModel.Categories);

            BrandWebModel updatedBrandModel = _mapper.Map <BrandWebModel>(updatedBrandDto);

            return(Ok(updatedBrandModel));
        }