Exemplo n.º 1
0
        public ActionResult CreateManufacturer(CreateManufacturerViewModel item)
        {
            var mapper = new MapperConfiguration(cg => cg.CreateMap <CreateManufacturerViewModel, ManufacturerDTO>()).CreateMapper();
            var mrDto  = mapper.Map <CreateManufacturerViewModel, ManufacturerDTO>(item);

            _manufacturerService.CreateManufacturer(mrDto);
            return(RedirectToAction("CreateManufacturer"));
        }
        public async Task <IActionResult> CreateManufacturer(CreateManufacturerViewModel createManufacturerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(createManufacturerViewModel));
            }

            var manufacturerDto = _mapper.Map <ManufacturerDTO>(createManufacturerViewModel);
            await _manufacturerService.AddAsync(manufacturerDto);

            await _manufacturerService.SaveChangesAsync();

            return(RedirectToAction(nameof(GetManufacturerList), CURRENT_CONTROLLER_NAME));
        }