Ejemplo n.º 1
0
        public bool UpdateProduct(ref MawarDBO mawarBDO, ref string message)
        {
            message = "Room updated successfully";
            bool ret = true;

            using (var MMEEntities = new HotelMawarMelatiEntities())
            {
                var   kamar_ID  = mawarBDO.Kamar_ID;
                Kamar kamarInDB = (from p in MMEEntities.Kamar
                                   where p.kamarID == kamar_ID
                                   select p).FirstOrDefault();
                if (kamarInDB == null)
                {
                    throw new Exception("No room(s) found with ID " + mawarBDO.Kamar_ID);
                }

                MMEEntities.Kamar.Remove(kamarInDB);
                kamarInDB.Harga  = mawarBDO.Harga;
                kamarInDB.Jenis  = mawarBDO.Jenis;
                kamarInDB.Jumlah = mawarBDO.Jumlah;
                MMEEntities.Entry(kamarInDB).State = System.Data.Entity.EntityState.Modified;
                MMEEntities.SaveChanges();
            }
            return(ret);
        }
Ejemplo n.º 2
0
 public void DeleteProduct(int id)
 {
     using (var MMEEntities = new HotelMawarMelatiEntities())
     {
         var c = (from p in MMEEntities.Kamar where p.kamarID == id select p).First();
         MMEEntities.Kamar.Remove(c);
         MMEEntities.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public void InsertProduct(MawarDBO 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 MMEEntities = new HotelMawarMelatiEntities())
            {
                MMEEntities.Kamar.Add(penerbangan);
                MMEEntities.SaveChanges();
            }
        }