Ejemplo n.º 1
0
        public async Task <ActionResult <BrandApi> > Create(CreateBrandApiRequest request)
        {
            var model    = _mapper.Map <CreateBrand>(request);
            var response = await _brandManager.Create(model);

            var modelApi = _mapper.Map <BrandApi>(response);

            return(Ok(modelApi));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(CreateBrandViewModel createBrandViewModel)
        {
            if (ModelState.IsValid)
            {
                Brand createBrand = _iMapper.Map <Brand>(createBrandViewModel);
                bool  isAdd       = await _iBrandManager.Create(createBrand);

                if (isAdd)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.ErrorMessage = "Failed to Save Brand";
                }
            }

            return(View(createBrandViewModel));
        }