public void Adding_Valid_Booking_Should_Return_No_Exceptions() { var booking = new BookingBuilder(this.seance) .WithGuid(Guid.NewGuid()) .WithBoughtBool(true) .WithPlaces("8:9:10:11") .Build(); bookingService.Add(booking); }
public async Task <IActionResult> Add([FromBody] CreateDto dto) { if (_service.IsExist(dto.Code)) { return(new ConflictObjectResult("code is exists")); } _service.Add(dto.Code, dto.Name); return(Ok()); }
private void buttonAddReservation_Click(object sender, EventArgs e) { if (listViewUsers.SelectedItems.Count != 0) { if (ValidationService.ValidateBookingDates(dateTimePickerStart.Value, dateTimePickerEnd.Value)) { var bookedDates = new List <DateTime>(); using (var context = ContextResolver.GetContext(connectionString)) { BookingService bookingService = new BookingService(context); bookedDates = bookedDatesService.GetAllBookedDays(bookingService.GetAllByRoomId(roomId)); } if (bookedDatesService.CheckIsBookedDates(dateTimePickerStart.Value, dateTimePickerEnd.Value, bookedDates)) { ListViewItem item = listViewUsers.SelectedItems[0]; Booking booking = new Booking() { StartDate = dateTimePickerStart.Value, EndDate = dateTimePickerEnd.Value, UserId = Convert.ToInt32(item.Text), RoomId = roomId }; using (var context = ContextResolver.GetContext(connectionString)) { BookingService bookingService = new BookingService(context); bookingService.Add(booking); } MessageBox.Show("New record has added"); this.Close(); } else { labelErrorBookedRoom.Visible = true; } } else { labelDatesValidation.Visible = true; } } else { labelError.Visible = true; } }
public IActionResult Add(AddBookingDTO booking) { if (_bookingService.Add(booking.RoomId, booking.Start, booking.End, booking.UserName)) { return(Ok()); } var problems = this.ProblemDetailsFactory.CreateProblemDetails(this.HttpContext, 400, "conflict detected", "conflict"); problems.Extensions.Add("errors", new Dictionary <string, List <string> >() { ["conflics"] = new List <string>() { "Booking conflict with another Booking" } }); problems.Extensions.Add("conflic", _bookingService.checkNoConflictQuery(booking.RoomId, booking.Start, booking.End)); problems.Extensions.Add("availables", _bookingService.RoomAvailableSpotsForDay(booking.RoomId, booking.Start)); return(BadRequest(problems)); }
// Booking Operations public void AddBooking(Booking booking) { var bookingData = new BookingService(); bookingData.Add(booking); }
public async Task <IActionResult> Post([FromBody] Booking booking) { return(CreatedAtAction("Get", new { id = booking.BookingID }, bookingService.Add(booking))); }