protected void CarGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Book")) { try { GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer); var startDate = DateTime.Parse(StartDateFilter.Text); var endDate = DateTime.Parse(EndDateFilter.Text); var price = double.Parse((row.FindControl("Price_Item") as Label).Text); var totalDay = Math.Ceiling((endDate - startDate).TotalDays); var carId = int.Parse((row.FindControl("Id_Item") as Label).Text); var userId = User.Identity.GetUserId(); Booking booking = new Booking { StartDate = startDate, EndDate = endDate, Status = nameof(BookingStatus.Booked), Cost = price * totalDay, CarId = carId, UserId = userId }; bookingRepository.AddBooking(booking); Response.Redirect(GetRouteUrl("Default", null)); } catch (Exception ex) { ErrorMessage.Text = ex.Message; } } }
public Booking Book(Guid employeeId, Guid hotelId, RoomType roomType, DateTime checkIn, DateTime checkOut) { var booking = new Booking(employeeId, hotelId, roomType, checkIn, checkOut, idGenerator.GenerateId()); ValidateBooking(booking); bookingRepository.AddBooking(booking); return(booking); }
public void AddBookingDetailsTestFailed() { var bookingrepo = new BookingRepository(bookcontextmock.Object); var bookingobj = bookingrepo.AddBooking(new Booking { BookingId = 3, HotelId = 20, UserId = 1, StartDate = Convert.ToDateTime("10/11/2020"), EndDate = Convert.ToDateTime("11/11/2020"), BillAmount = 6000.00 });; Assert.AreNotEqual(3, bookingobj.Id); }
public void AddBookingDetailTest() { var bookingrepo = new BookingRepository(bookcontextmock.Object); var bookingobj = bookingrepo.AddBooking(new Booking { BookingId = 3, HotelId = 1, UserId = 1, StartDate = Convert.ToDateTime("10/11/2020"), EndDate = Convert.ToDateTime("11/11/2020"), BillAmount = 6000.00 });; Assert.IsNotNull(bookingobj); }
public BookingResult Book([FromBody] BookingData bookingData) { if (!bookingData.IsValid()) { return new BookingResult() { Errors = new List <string>() { "Informações inválidas para a reserva" } } } ; StringValues values; if (Request.Headers.TryGetValue("UserID", out values)) { bookingData.SetPrice(); var userId = values[0]; BookingRepository.AddBooking(userId, bookingData); return(new BookingResult() { Id = bookingData.Id }); } else { return new BookingResult() { Errors = new List <string>() { "Usuário não identificado" } } }; }
public void AddBooking(int idClient, int idTourist, DateTime BookingDate) { Booking oBooking = new Booking(idClient, idTourist, BookingDate); ListBooking.AddBooking(oBooking); }
public HttpResponseMessage AddBooking(Booking item) { repo.AddBooking(item); return(new HttpResponseMessage(HttpStatusCode.Accepted)); }