public void ExcluirPrancha(int Id_Prancha) { Prancha pExcluir = BuscarPranchaPorId(Id_Prancha); pExcluir = contexto.PranchaSet.Where(p => p.Id_Prancha == pExcluir.Id_Prancha).FirstOrDefault(); if (pExcluir != null) { contexto.PranchaSet.Remove(pExcluir); contexto.SaveChanges(); } }
public void InserirPrancha(Prancha prancha) { try { contexto.PranchaSet.Add(prancha); contexto.SaveChanges(); }catch { prancha.Modelo = null; prancha.Marca = null; prancha.Medida = null; prancha.Cor = null; prancha.QtdQuilhas = 0; } }
public void EditarPrancha(int Id_Prancha, Prancha novosDadosPrancha) { //Procura por id e atualiza os dados em novoDadosPerson Prancha pranchaAntiga = BuscarPranchaPorId(Id_Prancha); if (pranchaAntiga != null) { pranchaAntiga.Modelo = novosDadosPrancha.Modelo; pranchaAntiga.Marca = novosDadosPrancha.Marca; pranchaAntiga.Medida = novosDadosPrancha.Medida; pranchaAntiga.Cor = novosDadosPrancha.Cor; pranchaAntiga.QtdQuilhas = novosDadosPrancha.QtdQuilhas; contexto.Entry(pranchaAntiga).State = System.Data.Entity.EntityState.Modified; contexto.SaveChanges(); } }