Exemplo n.º 1
0
 public void CreateBrand(BrandCreateModel model)
 {
     using (UnitOfWork unitOfWork = _unitOfWorkFactory.Create())
     {
         unitOfWork.Brands.Create(Mapper.Map <Brand>(model));
     }
 }
        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));
        }
Exemplo n.º 3
0
 public IActionResult CreateBrand(BrandCreateModel model)
 {
     _brandService.CreateBrand(model);
     return(RedirectToAction("Index"));
 }