Ejemplo n.º 1
0
        public async Task <IActionResult> AtualizarEmpresa(EmpresaViewComponent empresa)
        {
            var comprasViewModels = await _compraRepository.ObterTodasComprasEmpresas();

            if (comprasViewModels == null)
            {
                return(NotFound());
            }

            return(PartialView("_ListaDeEmpresas", comprasViewModels));
        }
        public async Task <IActionResult> Create(EmpresaViewComponent empresaViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(empresaViewModel));
            }

            var empresa = _Mapper.Map <Empresa>(empresaViewModel);

            await _EmpresaRepository.Adicionar(empresa);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> AtualizarEndereco(EmpresaViewComponent empresaViewComponent)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_AtualizarEndereco", empresaViewComponent));
            }

            await _EnderecoRepository.Atualizar(_Mapper.Map <Endereco>(empresaViewComponent.Endereco));

            return(RedirectToAction("Details", new { id = empresaViewComponent.Id }));

            //var url = Url.Action("ObterEndereco", "Empresas", new { id = empresaViewComponent.Endereco.EmpresaId });
            //return Json(new { success = true, url });
        }
        public async Task <IActionResult> Edit(Guid id, EmpresaViewComponent empresaViewModel)
        {
            if (id != empresaViewModel.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(empresaViewModel));
            }

            var empresa = _Mapper.Map <Empresa>(empresaViewModel);
            await _EmpresaRepository.Atualizar(empresa);

            return(RedirectToAction("Index"));
        }