public void update(customer cust, String type) { customer custme = hrs.customers.Where(x => (x.cust_id == cust.cust_id)).FirstOrDefault(); booking bkg = hrs.bookings.Where(x => (x.Booking_id == cust.booking.Booking_id)).FirstOrDefault(); ; if (type == custme.booking.room.room_type) { hrs.Entry(custme).CurrentValues.SetValues(cust); hrs.Entry(bkg).CurrentValues.SetValues(cust.booking); hrs.SaveChanges(); } else { room roo = hrs.rooms.Where(y => (y.room_ == cust.booking.Room_)).FirstOrDefault(); // for changing room ststus room rm = hrs.rooms.Where(y => (y.room_type == type && y.status == "unreserved")).FirstOrDefault(); cust.booking.Room_ = rm.room_; rm.status = "reserved"; cust.booking.room.status = rm.status; hrs.Entry(custme).CurrentValues.SetValues(cust); hrs.Entry(bkg).CurrentValues.SetValues(cust.booking); roo.status = "unreserved"; hrs.SaveChanges(); } }
public void addbooking(booking bk, customer cus, String rm_type) { customer cust = hrs.customers.Where(x => (x.fname == cus.fname && x.lastname == cus.lastname && x.cell_no == cus.cell_no && x.cnic == cus.cnic)).FirstOrDefault(); bk.cust_id = cust.cust_id; room roo = hrs.rooms.Where(x => (x.room_type == rm_type && x.status == "unreserved")).FirstOrDefault(); bk.Room_ = roo.room_; hrs.bookings.Add(bk); hrs.SaveChanges(); roo.status = "reserved"; hrs.SaveChanges(); booking bok = hrs.bookings.Where(x => (x.cust_id == cust.cust_id)).FirstOrDefault(); int cbok = bok.Booking_id; cust.booking_id = cbok; hrs.SaveChanges(); }
public List <room> checkavaiblty(room rm) { return(hrsda.checkavaiblty(rm)); }
public void addroom(room rm) { hrs.rooms.Add(rm); hrs.SaveChanges(); }
public List <room> checkavaiblty(room rm) { return(hrs.rooms.Where(x => (x.room_type == rm.room_type && x.status == rm.status)).ToList()); }