Example #1
0
        public bool UpdateProduct(ref PinguinBDO pinguinBDO, ref string message)
        {
            message = "Flight updated successfully";
            bool ret = true;

            using (var PAEntities = new PinguinAirEntities())
            {
                var         penerbanganID   = pinguinBDO.Penerbangan_ID;
                Penerbangan penerbanganInDB = (from p in PAEntities.Penerbangan
                                               where p.PenerbanganID == penerbanganID
                                               select p).FirstOrDefault();
                if (penerbanganInDB == null)
                {
                    throw new Exception("No flight(s) found with ID " + pinguinBDO.Penerbangan_ID);
                }

                PAEntities.Penerbangan.Remove(penerbanganInDB);
                penerbanganInDB.Pesawat  = pinguinBDO.Pesawat;
                penerbanganInDB.Harga    = pinguinBDO.Harga;
                penerbanganInDB.Asal     = pinguinBDO.Asal;
                penerbanganInDB.Tujuan   = pinguinBDO.Tujuan;
                penerbanganInDB.JlhKursi = pinguinBDO.Jlh_Kursi;
                PAEntities.Entry(penerbanganInDB).State = System.Data.Entity.EntityState.Modified;
                PAEntities.SaveChanges();
            }
            return(ret);
        }
Example #2
0
 public void DeleteProduct(int id)
 {
     using (var PAEntities = new PinguinAirEntities())
     {
         var c = (from p in PAEntities.Penerbangan where p.PenerbanganID == id select p).First();
         PAEntities.Penerbangan.Remove(c);
         PAEntities.SaveChanges();
     }
 }
Example #3
0
        public void InsertProduct(PinguinBDO pinguin)
        {
            Penerbangan penerbangan = new Penerbangan()
            {
                PenerbanganID = pinguin.Penerbangan_ID,
                Pesawat       = pinguin.Pesawat,
                JlhKursi      = (int)pinguin.Jlh_Kursi,
                Harga         = (int)pinguin.Harga,
                Asal          = pinguin.Asal,
                Tujuan        = pinguin.Tujuan,
                Terbang       = (DateTime)pinguin.Terbang
            };

            /*Console.WriteLine(pinguin.Penerbangan_ID);*/
            using (var PAEntities = new PinguinAirEntities())
            {
                PAEntities.Penerbangan.Add(penerbangan);
                PAEntities.SaveChanges();
            }
        }