public void Remove(FormaDePagamentoViewModel modelViewModel) { var model = Mapper.Map <FormaDePagamentoViewModel, FormaDePagamento>(modelViewModel); BeginTransaction(); _modelService.Remove(model); Commit(); }
public ActionResult Alterar(FormaDePagamentoViewModel FormaDePagamentoViewModel) { if (ModelState.IsValid) { _formaDePagamentoApp.Update(FormaDePagamentoViewModel); return(RedirectToAction("Index")); } return(View(FormaDePagamentoViewModel)); }
public void Salvar(FormaDePagamentoViewModel formaDePagamento) { var dbFormaDePagamento = formaDePagamento.Id == 0 ? new FormaDePagamento() : _formaDePagamentoRepository.Get(formaDePagamento.Id); if (dbFormaDePagamento == null) { throw new Exception("FormaDePagamento não pode ser alterado, pois não existe no banco."); } dbFormaDePagamento.NomeFormaDePagamento = formaDePagamento.NomeFormaDePagamento; dbFormaDePagamento.DtInativacao = formaDePagamento.Ativo ? (DateTime?)null : DateTime.Now; _formaDePagamentoRepository.AddOrUpdate(dbFormaDePagamento); _formaDePagamentoRepository.Commit(); }
public ValidationAppResult Add(FormaDePagamentoViewModel modelViewModel) { var model = Mapper.Map <FormaDePagamentoViewModel, FormaDePagamento>(modelViewModel); BeginTransaction(); var result = _modelService.AdicionarFormaDePagamento(model); if (!result.IsValid) { return(DomainToApplicationResult(result)); } Commit(); return(DomainToApplicationResult(result)); }
public ActionResult Editar(FormaDePagamentoViewModel formaDePagamento) { if (!ModelState.IsValid) { return(View("FormaDePagamento", formaDePagamento)); } try { _formaDePagamentoApp.Salvar(formaDePagamento); } catch (Exception ex) { TempData["Alerta"] = ex.Message; return(View("FormaDePagamento", formaDePagamento)); } return(RedirectToAction("Index")); }
public ActionResult Cadastrar(FormaDePagamentoViewModel FormaDePagamentoViewModel) { if (ModelState.IsValid) { var result = _formaDePagamentoApp.Add(FormaDePagamentoViewModel); if (!result.IsValid) { foreach (var validationAppError in result.Erros) { ModelState.AddModelError(string.Empty, validationAppError.Message); } return(View(FormaDePagamentoViewModel)); } return(RedirectToAction("Index")); } return(View(FormaDePagamentoViewModel)); }