public string Update(string input) { System.Console.Write("Tanggal Kembali : "); DateTime tgl_kembali = Convert.ToDateTime(System.Console.ReadLine()); TrPinjam trans = GetById(input); trans.TglKembali = tgl_kembali; try { _context.Entry(trans).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); System.Console.WriteLine("Update data berhasil!"); } catch (Exception ex) { System.Console.Write(ex.InnerException); } return(input); }
public void Insert() { System.Console.Write("Kode Transaksi : "); string kode_trans = System.Console.ReadLine(); System.Console.Write("Tanggal Pinjam : "); DateTime tgl_pinjam = Convert.ToDateTime(System.Console.ReadLine()); System.Console.Write("Kode Pelanggan : "); string kode_pelanggan = System.Console.ReadLine(); System.Console.Write("Kode Video : "); string kode_video = System.Console.ReadLine(); System.Console.Write("Lama Pinjam : "); int lama_pinjam = Convert.ToInt16(System.Console.ReadLine()); TrPinjam trans = new TrPinjam() { KdTransaksi = kode_trans, TglPinjam = tgl_pinjam, KdPelanggan = kode_pelanggan, KdVideo = kode_video, LamaPinjam = lama_pinjam }; try { _context.TrPinjams.Add(trans); var result = _context.SaveChanges(); System.Console.WriteLine("Insert data berhasil!"); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }