public bool CadastrarVeiculo(VeiculoViewModel model) { CSharpTestEntities tEntity = new CSharpTestEntities(); TB_CHASSI obj = new TB_CHASSI(); try { if (model != null) { obj.COD_CHASSI = model.COD_CHASSI; obj.TIPO_VEICULO = model.TIPO_VEICULO; obj.NUM_PASSAGEIROS = model.NUM_PASSAGEIROS; obj.COR = model.COR; obj.DT_CADASTRO = DateTime.Now; obj.DT_ALTERACAO = DateTime.Now; tEntity.TB_CHASSI.Add(obj); tEntity.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool AlterarVeiculo(VeiculoViewModel model) { CSharpTestEntities tEntity = new CSharpTestEntities(); try { var obj = tEntity.TB_CHASSI.Where(x => x.COD_CHASSI == model.COD_CHASSI).FirstOrDefault(); if (obj != null) { obj.COD_CHASSI = model.COD_CHASSI; obj.TIPO_VEICULO = model.TIPO_VEICULO; obj.COR = model.COR; obj.DT_ALTERACAO = DateTime.Now; tEntity.SaveChanges(); return(true); } else { return(false); } return(true); } catch (Exception) { throw; } }