public bool UpdateProduct(ref KasurEmpukBDO kasurBDO, ref string message) { message = "Room updated successfully"; bool ret = true; using (var KEEntities = new HotelKasurEmpukEntities()) { var kamar_ID = kasurBDO.Kamar_ID; Kamar kamarInDB = (from p in KEEntities.Kamar where p.kamarID == kamar_ID select p).FirstOrDefault(); if (kamarInDB == null) { throw new Exception("No room(s) found with ID " + kasurBDO.Kamar_ID); } KEEntities.Kamar.Remove(kamarInDB); kamarInDB.Harga = kasurBDO.Harga; kamarInDB.Jenis = kasurBDO.Jenis; kamarInDB.Jumlah = kasurBDO.Jumlah; KEEntities.Entry(kamarInDB).State = System.Data.Entity.EntityState.Modified; KEEntities.SaveChanges(); } return(ret); }
public void DeleteProduct(int id) { using (var KEEntities = new HotelKasurEmpukEntities()) { var c = (from p in KEEntities.Kamar where p.kamarID == id select p).First(); KEEntities.Kamar.Remove(c); KEEntities.SaveChanges(); } }
public void InsertProduct(KasurEmpukBDO mawar) { Kamar penerbangan = new Kamar() { kamarID = mawar.Kamar_ID, Jumlah = (int)mawar.Jumlah, Harga = (int)mawar.Harga, Jenis = mawar.Jenis }; /*Console.WriteLine(mawar.Penerbangan_ID);*/ using (var KEEntities = new HotelKasurEmpukEntities()) { KEEntities.Kamar.Add(penerbangan); KEEntities.SaveChanges(); } }