Ejemplo n.º 1
0
        public int Updatemahasiswa(int input)
        {
            System.Console.Write("MASUKKAN NAMA BARU MAHASISWA     : ");
            string Nama = System.Console.ReadLine();

            System.Console.Write("MASUKKAN ALAMAT BARU MAHASISWA : ");
            string alamat = System.Console.ReadLine();

            System.Console.Write("MASUKKAN ID      : ");
            string id_mhs = System.Console.ReadLine();

            var getmhs = _context.mahasiswa.Find(Convert.ToInt16(id_mhs));

            if (getmhs == null)
            {
                System.Console.Write("TIDAK ADA ID MAHASISWA : " + id_mhs);
            }
            else
            {
                mahasiswa mahasiswa = GetById(input);
                mahasiswa.nama   = Nama;
                mahasiswa.alamat = alamat;
                _context.Entry(mahasiswa).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            return(input);
        }
Ejemplo n.º 2
0
        public void Insert()
        {
            Console.Clear();
            System.Console.Write("Masukkan ID Mahasiswa : ");
            string ID_Mahasiswa = Console.ReadLine();

            System.Console.Write("Nama Mahasiswa : ");
            string Nama_Mahasiswa = System.Console.ReadLine();

            System.Console.Write("Jenis Kelamin : ");
            string jenis_kelamin = System.Console.ReadLine();

            System.Console.Write("Alamat : ");
            string alamat_mahasiswa = System.Console.ReadLine();

            System.Console.Write("Email : ");
            string Email = System.Console.ReadLine();

            System.Console.Write("Telepon : ");
            string Telepon = System.Console.ReadLine();

            System.Console.Write("ID Prodi : ");
            string Id_Prodi = System.Console.ReadLine();

            System.Console.Write("ID Dosen : ");
            string Id_dosen = System.Console.ReadLine();

            System.Console.Write("Jurusan : ");
            string prodi = System.Console.ReadLine();

            mahasiswa call = new mahasiswa();

            {
                call.id            = ID_Mahasiswa;
                call.nama          = Nama_Mahasiswa;
                call.jenis_kelamin = jenis_kelamin;
                call.alamat        = alamat_mahasiswa;
                call.email         = Email;
                call.telepon       = Telepon;
                call.id_prodi      = Id_Prodi;
                call.id_dosen      = Id_dosen;
                call.prodi         = prodi;
            };
            try
            {
                _context.mahasiswa.Add(call);
                var result = _context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }