public int UpdateDosen(int input2) { System.Console.Write("MASUKKAN NAMA BARU : "); string Nama = System.Console.ReadLine(); System.Console.Write("MASUKKAN ID_MAKUL BARU : "); string id_makul = System.Console.ReadLine(); System.Console.Write("MASUKKAN ULANG ID : "); string id_dsn = System.Console.ReadLine(); var getdsn = mhs_context.PENGAJARs.Find(Convert.ToInt16(id_dsn)); if (getdsn == null) { System.Console.Write("TIDAK ADA ID DOSEN : " + id_dsn); } else { PENGAJAR dosen = GetById2(input2); dosen.NAME = Nama; dosen.ID_MAKUL = Convert.ToInt16(id_makul); mhs_context.Entry(dosen).State = System.Data.Entity.EntityState.Modified; mhs_context.SaveChanges(); } return(input2); }
// =========================================== INSERT ============================================= public void InsertDOSEN() { Console.Clear(); System.Console.Write("NAMA DOSEN : "); string Nama_DOSEN = System.Console.ReadLine(); System.Console.Write("ID MAKUL : "); string ID_MAKUL = System.Console.ReadLine(); PENGAJAR call = new PENGAJAR(); { call.NAME = Nama_DOSEN; call.ID_MAKUL = Convert.ToUInt16(ID_MAKUL); }; try { mhs_context.PENGAJARs.Add(call); var result = mhs_context.SaveChanges(); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }