public void BookRoom(BookingSchedule bookingSchedule) { var booking = _bookingContext.BookingSchedules.Create(); _bookingContext.BookingSchedules.Add(booking); _bookingContext.SaveChanges(); }
public async Task <Booking> InsertIntoDatabase(Booking booking) { return(await Task.Run(() => { var e = this.dbContext.Bookings.Add(booking); dbContext.SaveChanges(); return e.Entity; })); }
public ActionResult Create([Bind(Include = "Name,Size,Location,Equipment")] MeetingRoom meetingRoom) { try { if (ModelState.IsValid) { if (db.MeetingRooms.FirstOrDefault(m => m.Name == meetingRoom.Name) == null) { db.MeetingRooms.Add(meetingRoom); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "A meeting room with the same name already exists."); } } } catch (RetryLimitExceededException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(meetingRoom)); }