public void Atualizar(int id, ClienteUpdateViewModel clienteUpdateViewModel) { Cliente cliente = clienteBusiness.GetById(id); Map(clienteUpdateViewModel, cliente); clienteBusiness.Update(cliente); }
public ActionResult Edit(ClienteUpdateViewModel viewModel) { var config = new MapperConfiguration(cfg => cfg.CreateMap <ClienteUpdateViewModel, Cliente>()); var mapper = config.CreateMapper(); Cliente cliente = mapper.Map <Cliente>(viewModel); Response response = svc.Update(cliente); if (response.Sucesso) { return(RedirectToAction("Index")); } ViewBag.Erros = response.Mensagem; return(View()); }
public ClienteServiceTest() { _entity = _fixture.Build <Cliente>().Create(); _insertViewModel = _fixture.Create <ClienteInsertViewModel>(); _updateViewModel = _fixture.Create <ClienteUpdateViewModel>(); _mockBusiness = new Mock <IClienteBusiness>(); _exception = _fixture.Create <Exception>(); _mockMapper = new Mock <IMapper>(); _mockNotification = new Mock <INotification>(); _service = new ClienteService(_mockBusiness.Object, _mockMapper.Object); }
public async Task <IActionResult> Atualizar(ClienteUpdateViewModel updateViewModel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <ClienteUpdateViewModel, ClienteDTO>(); }); IMapper mapper = configuration.CreateMapper(); ClienteDTO cliente = mapper.Map <ClienteDTO>(updateViewModel); try { await _clienteService.Update(cliente); return(RedirectToAction("Index", "Cliente")); } catch (Exception ex) { ViewBag.ErroGenerico = ex.Message; } return(View()); }
public ActionResult Edit(int?id) { if (!id.HasValue) { return(RedirectToAction("Index")); } SingleResponse <Cliente> responseCliente = svc.GetByID(id.Value); if (!responseCliente.Sucesso) { return(RedirectToAction("Index")); } var config = new MapperConfiguration(cfg => cfg.CreateMap <Cliente, ClienteUpdateViewModel>()); var mapper = config.CreateMapper(); ClienteUpdateViewModel cliente = mapper.Map <ClienteUpdateViewModel>(responseCliente.SingleData); return(View(cliente)); }
public ActionResult Atualizar(int id, [FromBody] ClienteUpdateViewModel aluno) { clienteService.Atualizar(id, aluno); return(Ok()); }