public bool Post([FromBody] Booking booking) { if (!this.bookings.items.ContainsKey(booking.Id) && !SeatManage.templist1.ContainsKey(booking.SeatId)) { SeatManage.Show(booking.SeatId); return(this.bookings.Add(booking)); } else { return(false); } }
public BookingNewController(Repository <Booking> booking) { this.bookings = booking; IEnumerator <Seating> list = SeatManage.templist1.Values.GetEnumerator(); IEnumerator <Booking> booklist = this.bookings.GetAll().GetEnumerator(); while (list.MoveNext()) { while (booklist.MoveNext()) { if (list.Current.Id == booklist.Current.SeatId) { //DateTimeOffset offset ; //DateTimeOffset.TryParse(booklist.Current.EndTime, out offset); //if ( DateTimeOffset.Now >=offset ) //{ // Seating seat= SeatManage.templist1[booklist.Current.SeatId]; // SeatManage.Hide(seat); // this.Delete(booklist.Current.Id); //} var checkDate = DateTime.Compare(DateTime.Now, booklist.Current.EndTime); if (checkDate >= 0) { Seating seat = SeatManage.templist1[booklist.Current.SeatId]; SeatManage.Hide(seat); this.Delete(booklist.Current.Id); } } else { booklist = this.bookings.GetAll().GetEnumerator(); } } } }