예제 #1
0
        public ActionResult Excluir(AlterarClienteViewModel modelo)
        {
            try
            {
                this.ClienteServico.Excluir(Mapper.Map <AlterarClienteViewModel, Cliente>(modelo));
                ModelState.AddModelError(string.Empty, Recurso.ExcluidoSucesso);
            }
            catch (EntidadeNaoExistenteException ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError(string.Empty, Recurso.MPAlertaNaoPodeDeletar);
            }

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Alterar(AlterarClienteViewModel modelo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    this.ClienteServico.Alterar(Mapper.Map <AlterarClienteViewModel, Cliente>(modelo));
                    ModelState.AddModelError(string.Empty, Recurso.AlteradoSucesso);
                    return(RedirectToAction("Index"));
                }
                catch (EntidadeNaoExistenteException ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }

            return(this.Alterar(modelo.Id));
        }
 public AlterarClientePage(Cliente cliente)
 {
     InitializeComponent();
     BindingContext = new AlterarClienteViewModel(cliente, Navigation);
 }