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 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(); } }
public IEnumerable <KasurEmpukBDO> GetAllProduct() { List <Kamar> li = new List <Kamar>(); List <KasurEmpukBDO> temp = new List <KasurEmpukBDO>(); using (var KEEntities = new HotelKasurEmpukEntities()) { li = (from p in KEEntities.Kamar select p).ToList(); } foreach (var c in li) { KasurEmpukBDO data = new KasurEmpukBDO() { Kamar_ID = c.kamarID, Jumlah = (int)c.Jumlah, Harga = (int)c.Harga, Jenis = c.Jenis }; temp.Add(data); } return(temp); }
public KasurEmpukBDO GetProduct(int id) { KasurEmpukBDO kasurBDO = null; using (var KEEntities = new HotelKasurEmpukEntities()) { Kamar kamar = (from p in KEEntities.Kamar where p.kamarID == id select p).FirstOrDefault(); if (kamar != null) { kasurBDO = new KasurEmpukBDO() { Kamar_ID = kamar.kamarID, Jumlah = (int)kamar.Jumlah, Harga = (int)kamar.Harga, Jenis = kamar.Jenis, }; } } return(kasurBDO); }