示例#1
0
        public ActionResult Create(ClienteEnderecoViewModel clienteEnderecoViewModel)
        {
            if (ModelState.IsValid)
            {
                clienteEnderecoViewModel.ClienteId = Guid.NewGuid();
                clienteEnderecoViewModel.TipoQualquer = new TipoQualquerViewModel() {TipoQualquerId = 1, TipoNome = "QualquerNome" };
                _clietenteClienteAppService.Adicionar(clienteEnderecoViewModel);
                return RedirectToAction("Index");
            }

            return View(clienteEnderecoViewModel);
        }
示例#2
0
        public ClienteEnderecoViewModel Adicionar(ClienteEnderecoViewModel clienteEnderecoViewModel)
        {
            var cliente = Mapper.Map<ClienteEnderecoViewModel, Cliente>(clienteEnderecoViewModel);
            var endereco = Mapper.Map<ClienteEnderecoViewModel, Endereco>(clienteEnderecoViewModel);
            var tipoqualquer = Mapper.Map<ClienteEnderecoViewModel, TipoQualquer>(clienteEnderecoViewModel);
            cliente.Enderecos.Add(endereco);
            cliente.TipoQualquer = tipoqualquer;
            cliente.DataCadastro = DateTime.Now;

            var clienteReturn = _clieteService.Adicionar(cliente);

            clienteEnderecoViewModel = Mapper.Map<Cliente, ClienteEnderecoViewModel>(clienteReturn);

            return clienteEnderecoViewModel;
        }