public int guardarDonante([FromBody] DonantesAF oDonantesAF) { int rpta = 0; try { using (BDAcaassAFContext bd = new BDAcaassAFContext()) { Donantes oDonantes = new Donantes(); oDonantes.IdDonante = oDonantesAF.IidDonante; oDonantes.Nombre = oDonantesAF.nombre; oDonantes.Telefono = oDonantesAF.telefono; oDonantes.Direccion = oDonantesAF.direccion; oDonantes.Dhabilitado = 1; bd.Donantes.Add(oDonantes); bd.SaveChanges(); rpta = 1; } } catch (Exception ex) { rpta = 0; } return(rpta); }
public DonantesAF RecuperarDonante(int idDonante) { using (BDAcaassAFContext bd = new BDAcaassAFContext()) { DonantesAF oDonantesAF = new DonantesAF(); Donantes oDonantes = bd.Donantes.Where(p => p.IdDonante == idDonante).First(); oDonantesAF.IidDonante = oDonantes.IdDonante; oDonantesAF.nombre = oDonantes.Nombre; oDonantesAF.telefono = oDonantes.Telefono; oDonantesAF.direccion = oDonantes.Direccion; return(oDonantesAF); } }
public int modificarDonante([FromBody] DonantesAF oDonanteAF) { int rpta = 0; try { using (BDAcaassAFContext bd = new BDAcaassAFContext()) { Donantes oDonante = bd.Donantes.Where(p => p.IdDonante == oDonanteAF.IidDonante).First(); oDonante.IdDonante = oDonanteAF.IidDonante; oDonante.Nombre = oDonanteAF.nombre; oDonante.Telefono = oDonanteAF.telefono; oDonante.Direccion = oDonanteAF.direccion; bd.SaveChanges(); rpta = 1; } } catch (Exception ex) { rpta = 0; } return(rpta); }