public int Alterar(TipoAluguelViewModel p) { TipoAluguel tipoAluguel = new TipoAluguel() { Id = p.Id, Nome = p.Nome, Valor = p.Valor, }; return(tipoAluguel.Alterar()); }
private TipoAluguelViewModel BuscarTipoAluguelPorId(int id) { var tipoAluguel = new TipoAluguel().BuscarTipoAluguelPorId(id); return(new TipoAluguelViewModel() { Id = tipoAluguel.Id, Nome = tipoAluguel.Nome, Valor = tipoAluguel.Valor, }); }
internal int Alterar(TipoAluguel taAlterado) { try { using (avrasContext contexto = new avrasContext()) { var tpAtual = contexto.TipoAluguel.Where(p => p.Id == taAlterado.Id).FirstOrDefault(); tpAtual.Nome = taAlterado.Nome; tpAtual.Valor = taAlterado.Valor; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
public List <TipoAluguelViewModel> Listar() { var tipoAlugueis = new TipoAluguel().BuscarTipoAluguel(); if (tipoAlugueis != null && tipoAlugueis.Count > 0) { return((from tipoAluguel in tipoAlugueis select new avras.cl.ViewModels.TipoAluguelViewModel() { Id = tipoAluguel.Id, Nome = tipoAluguel.Nome, Valor = tipoAluguel.Valor, }).ToList()); } else { return(null); } }
internal int Gravar(TipoAluguel tipoAluguel) { try { using (avrasContext contexto = new avrasContext()) { if (tipoAluguel.Id == 0) { contexto.TipoAluguel.Add(tipoAluguel); } else { contexto.TipoAluguel.Attach(tipoAluguel); } return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
public int Gravar(TipoAluguelViewModel p) { int result; TipoAluguel tipoAluguel = new TipoAluguel() { Nome = p.Nome, Valor = p.Valor, }; if (p.Id != 0) { tipoAluguel.Id = p.Id; result = tipoAluguel.Alterar(); } else { result = tipoAluguel.Gravar(); } return(result); }