示例#1
0
 public void DeleteHotel(int id)
 {
     using (HotelmanagementEntities db = new HotelmanagementEntities())
     {
         hotel h = db.hotels.Where(p => p.hotelid == id).FirstOrDefault();
         db.Entry(h).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
 public bool DeleteBooking(int bookingId)
 {
     using (HotelmanagementEntities db = new HotelmanagementEntities())
     {
         bool status = false;
         try
         {
             booking booking = db.bookings.Where(x => x.bookingid == bookingId).AsNoTracking().FirstOrDefault();
             booking.bookingstatus   = "Deleted";
             db.Entry(booking).State = EntityState.Modified;
             if (db.SaveChanges() > 0)
             {
                 status = true;
             }
             return(status);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             return(false);
         }
     }
 }
 public bool UpdateBookingStatus(int id, string status)
 {
     using (HotelmanagementEntities db = new HotelmanagementEntities())
     {
         bool updated = false;
         try
         {
             booking booking = db.bookings.AsNoTracking().Where(x => x.bookingid == id).FirstOrDefault();
             booking.bookingstatus   = status;
             db.Entry(booking).State = EntityState.Modified;
             if (db.SaveChanges() > 0)
             {
                 updated = true;
             }
             return(updated);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             return(false);
         }
     }
 }