public void update(Booking booking) { bookingNameLabel.Text = booking.Topic; dateLabel.Text = booking.StartDate.ToShortDateString(); dayLabel.Text = booking.StartDate.DayOfWeek.ToString (); timeLabel.Text = booking.StartDate.ToShortTimeString() + " - " + booking.EndDate.ToShortTimeString(); }
/// <summary>Creates or updates a booking.</summary> /// <param name="booking">The booking to create/update.</param> /// <param name="wasAChange">If the call changed a booking instead of creating a new one, this will be true.</param> /// <returns>The result of the method call.</returns> public static RequestResult CreateOrUpdateBooking(Booking booking, out bool wasAChange) { wasAChange = false; Booking[] bookings; var result = ServiceClients.BookingManager.GetBookingsByDate(out bookings, booking.StartTime.Date); if (result != RequestStatus.Success) return RequestResult.InvalidInput; var temp = bookings.FirstOrDefault(b => BookingsOverlap(b, booking)); RequestStatus rs; if (temp == null) rs = ServiceClients.BookingManager.CreateBooking(PersonModel.loggedInUser.Token, ref booking); else { temp.StartTime = booking.StartTime; temp.EndTime = booking.EndTime; rs = ServiceClients.BookingManager.ChangeTimeOfBooking(PersonModel.loggedInUser.Token, ref temp); wasAChange = true; } switch (rs) { case RequestStatus.Success: return RequestResult.Success; case RequestStatus.AccessDenied: return RequestResult.AccessDenied; case RequestStatus.InvalidInput: return RequestResult.InvalidInput; default: return RequestResult.Error; } }
protected void btnBook_Click(object sender, EventArgs e) { Booking booking = new Booking(); booking.BookingDate = DateTime.Now; booking.BookingNo = BookingDB.CreateBookingNum(Session["CustId"].ToString(), ddlPackage.SelectedItem.Value.ToString()); booking.TravelerCount = Int32.Parse(ddlTravelCount.SelectedItem.Value); booking.CustomerId = Int32.Parse(Session["CustId"].ToString()); booking.TripTypeId = ddlTripType.SelectedItem.Value.ToString(); booking.PackageId = Int32.Parse(ddlPackage.SelectedItem.Value); //lblMessage.Text = "booking = " + booking.BookingDate + " " + booking.BookingNo + " " + booking.TravelerCount + " " + // booking.CustomerId + " " + booking.TripTypeId + " " + booking.PackageId; if (BookingDB.InsertBooking(booking)) { lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = "Booking succeeded! Thank you for Booking with Travel Experts."; // TODO: reset fields } else { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Booking failed!. Please contact Travel Experts"; } //Response.Redirect("UserHome.aspx"); }
/// <summary> /// Update an existing Booking entry. /// </summary> /// <param name="p_booking">Bookingobject with an ID.</param> /// <returns>Updated Bookingobject.</returns> public Booking Update(Booking p_booking) { using (var context = new FhdwHotelContext()) { using (var transaction = context.Database.BeginTransaction()) { try { p_booking.Hotel = context.Hotel.SingleOrDefault(h => h.ID == p_booking.Hotel.ID); context.Booking.Add(p_booking); context.SaveChanges(); transaction.Commit(); return p_booking; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); transaction.Rollback(); return null; } } } }
public Booking AddBooking(Booking booking) { Bookings.Add(booking); SaveChanges(); return booking; }
private async void setup() { Functions functions = new Functions(); JsonValue list = await functions.getBookings (this.Student.StudentID.ToString()); JsonValue results = list ["Results"]; tableItems = new List<Booking>(); if (list ["IsSuccess"]) { for (int i = 0; i < results.Count; i++) { if (DateTime.Parse (results [i] ["ending"]) < DateTime.Now) { Booking b = new Booking (results [i]); if (b.BookingArchived == null) { tableItems.Add (b); } } } tableItems.Sort((x, y) => DateTime.Compare(x.StartDate, y.StartDate)); this.TableView.ReloadData (); } else { createAlert ("Timeout expired", "Please reload view"); } if (tableItems.Count == 0) { createAlert ("No Bookings", "You do not have any past bookings"); } }
private void AddEditBooking_Load(object sender, EventArgs e) { var unitOfWork = new UnitOfWork(); cbType.DataSource = unitOfWork.BookingClassificationRepository.Get().ToList(); cbType.DisplayMember = "ClassificationName"; cbType.ValueMember = "Id"; var startDate = DateTime.Today; startDate.AddSeconds(-startDate.Second); startDate.AddMinutes(-startDate.Minute); dtpBookingTime.Value = startDate; if (currentBookingID != null) { currentBooking = unitOfWork.BookingRepository.Get(null, null, "Employee,BookingClasification,BookingNotes").Where(x => x.Id == currentBookingID).FirstOrDefault(); btnSave.Text = "Save Changes"; dtpBookingTime.Value = currentBooking.BookingDate; tbName.Text = currentBooking.Name; tbContactNumber.Text = currentBooking.ContactNumber; tbEmail.Text = currentBooking.Email; cbType.SelectedValue = currentBooking.BookingClasification.Id; newbookingNotes = currentBooking.BookingNotes.Where(x => x.DateInactive == null).ToList(); } RebindNotes(); }
public IView Book(int roomId, DateTime startDate, DateTime endDate, string comments) { this.Authorize(Roles.User, Roles.VenueAdmin); var room = this.Data.RepositoryWithRooms.Get(roomId); if (room == null) { return this.NotFound(string.Format("The room with ID {0} does not exist.", roomId)); } if (startDate > endDate) { throw new ArgumentException("The date range is invalid."); } var availablePeriod = room.AvailableDates.FirstOrDefault(d => d.StartDate <= startDate || d.EndDate >= endDate); if (availablePeriod == null) { throw new ArgumentException(string.Format("The room is not available to book in the period {0:dd.MM.yyyy} - {1:dd.MM.yyyy}.", startDate, endDate)); } decimal totalPrice = (endDate - startDate).Days * room.PricePerDay; var booking = new Booking(this.CurrentUser, startDate, endDate, totalPrice, comments); room.Bookings.Add(booking); this.CurrentUser.Bookings.Add(booking); this.UpdateRoomAvailability(startDate, endDate, room, availablePeriod); return this.View(booking); }
public IHttpActionResult PutBooking(int id, Booking booking) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != booking.Booking_id) { return BadRequest(); } db.Entry(booking).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public Invoice(int invoice_id, int entity_id, int invoice_type_id, int booking_id, int payer_organisation_id, int payer_patient_id, int non_booking_invoice_organisation_id, string healthcare_claim_number, int reject_letter_id, string message, int staff_id, int site_id, DateTime invoice_date_added, decimal total, decimal gst, decimal receipts_total, decimal vouchers_total, decimal credit_notes_total, decimal refunds_total, bool is_paid, bool is_refund, bool is_batched, int reversed_by, DateTime reversed_date, DateTime last_date_emailed) { this.invoice_id = invoice_id; this.entity_id = entity_id; this.invoice_type = new IDandDescr(invoice_type_id); this.booking = booking_id == -1 ? null : new Booking(booking_id); this.payer_organisation = payer_organisation_id == 0 ? null : new Organisation(payer_organisation_id); this.payer_patient = payer_patient_id == -1 ? null : new Patient(payer_patient_id); this.non_booking_invoice_organisation = non_booking_invoice_organisation_id == -1 ? null : new Organisation(non_booking_invoice_organisation_id); this.healthcare_claim_number = healthcare_claim_number; this.reject_letter = reject_letter_id == -1 ? null : new Letter(reject_letter_id); this.message = message; this.staff = new Staff(staff_id); this.site = site_id == -1 ? null : new Site(site_id); this.invoice_date_added = invoice_date_added; this.total = total; this.gst = gst; this.receipts_total = receipts_total; this.vouchers_total = vouchers_total; this.credit_notes_total = credit_notes_total; this.refunds_total = refunds_total; this.is_paid = is_paid; this.is_refund = is_refund; this.is_batched = is_batched; this.reversed_by = reversed_by == -1 ? null : new Staff(reversed_by); this.reversed_date = reversed_date; this.last_date_emailed = last_date_emailed; }
//add a new booking passing roombooking means extra unneeded data is being shunted around. //public void AddNewBookingToDB(int RoomIdfk, DateTime BookingFrom, DateTime BookingTo, Decimal Roomcost) { public void AddNewBookingToDB(RoomBooking myRB) { using (var context = new Sunshine_HotelEntities1()) { // CREATE a new booking var newbooking = new Booking(); newbooking.RoomIDFK = myRB.RoomIdfk; newbooking.BookingFrom = myRB.BookingFrom.Date; newbooking.BookingTo = myRB.BookingTo.Date; //add in the cost of the room extracted from the dictionary newbooking.RoomCost = myRB.roomCost; // RoomCost = (decimal) newbooking.RoomCost; //update db context.Bookings.Add(newbooking); context.SaveChanges(); var BookedConfirmationMessage = Environment.NewLine + "You have booked Room " + myRB.RoomIdfk + Environment.NewLine + "From " + myRB.BookingFrom + " To " + Environment.NewLine + myRB.BookingTo + Environment.NewLine + " For " + (string.Format("{0:C}", myRB.roomCost)); //show a confirmation message MessageBox.Show(BookedConfirmationMessage); } }
public TimetableModel(List<Room> Rooms, List<TimeSlot> Times, Booking[,] Bookings, DateTime Day) { this.Rooms = Rooms; this.Times = Times; this.Bookings = Bookings; this.Day = Day; ValidTimetable = true; }
/// <summary> /// Constructor that prefills the fields. /// </summary> /// <param name="pk"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="name"></param> public Event(Booking aBooking) { this.booking = aBooking; this.Start = aBooking.Startdatetime; this.End = aBooking.Enddatetime; this.PK = aBooking.Bookingid; }
private static int milesForBooking(Booking booking) { if (booking.GetType() == typeof(Flight)) { return ((Flight)booking).Miles; } return 0; }
public void CreateBooking(Booking booking) { this.bookings.Add(booking); this.hotelRooms .GetById(booking.HotelRoomsId) .Booked = true; this.bookings.SaveChanges(); }
public void AddBooking(String username, int referenceNumber) { var booking = new Booking(); booking.reference_number = referenceNumber; booking.creator = username; db.Bookings.InsertOnSubmit(booking); db.SubmitChanges(); }
public BookingChangeHistory(int booking_change_history_id, int booking_id, int moved_by, DateTime date_moved, int booking_change_history_reason_id, DateTime previous_datetime) { this.booking_change_history_id = booking_change_history_id; this.booking = new Booking(booking_id); this.moved_by = moved_by; this.date_moved = date_moved; this.booking_change_history_reason = new IDandDescr(booking_change_history_reason_id); this.previous_datetime = previous_datetime; }
public void CancelBooking(Booking booking) { CancelRequest cancelrequest = new CancelRequest(); cancelrequest.Signature = signature; CancelRequestData cancelrequestdata = new CancelRequestData(); cancelrequest.CancelRequestData = cancelrequestdata; cancelrequestdata.CancelBy = CancelBy.Journey; CancelJourney canceljourney = new CancelJourney(); cancelrequestdata.CancelJourney = canceljourney; CancelJourneyRequest canceljourneyrequest = new CancelJourneyRequest(); canceljourney.CancelJourneyRequest = canceljourneyrequest; //Journey[] journeys = new Journey[1]; //journeys[0] = new Journey(); //journeys[0].Segments = new Segment[1];//here i am assuming this is a direct journey with one segment //journeys[0].Segments[0] = new Segment(); //journeys[0].Segments[0].ActionStatusCode = booking.Journeys[0].Segments[0].ActionStatusCode; //journeys[0].Segments[0].DepartureStation = booking.Journeys[0].Segments[0].DepartureStation; //journeys[0].Segments[0].ArrivalStation = booking.Journeys[0].Segments[0].ArrivalStation; //journeys[0].Segments[0].STD = booking.Journeys[0].Segments[0].STD; //journeys[0].Segments[0].STA = booking.Journeys[0].Segments[0].STA; //journeys[0].Segments[0].FlightDesignator = booking.Journeys[0].Segments[0].FlightDesignator;//flight designator means carrier code canceljourneyrequest.Journeys = new Journey[1]; canceljourneyrequest.Journeys[0] = new Journey(); canceljourneyrequest.Journeys[0].Segments = new Segment[booking.Journeys[0].Segments.Length]; for (int i = 0; i < booking.Journeys[0].Segments.Length; i++) { canceljourneyrequest.Journeys[0].Segments[i] = new Segment(); canceljourneyrequest.Journeys[0].Segments[i].STA = booking.Journeys[0].Segments[i].STA; canceljourneyrequest.Journeys[0].Segments[i].STD = booking.Journeys[0].Segments[i].STD; canceljourneyrequest.Journeys[0].Segments[i].ArrivalStation = booking.Journeys[0].Segments[i].ArrivalStation; canceljourneyrequest.Journeys[0].Segments[i].DepartureStation = booking.Journeys[0].Segments[i].DepartureStation; canceljourneyrequest.Journeys[0].Segments[i].FlightDesignator = booking.Journeys[0].Segments[i].FlightDesignator; canceljourneyrequest.Journeys[0].Segments[i].Fares = new Fare[1]; canceljourneyrequest.Journeys[0].Segments[i].Fares[0] = new Fare(); canceljourneyrequest.Journeys[0].Segments[i].Fares[0].CarrierCode = booking.Journeys[0].Segments[i].Fares[0].CarrierCode; canceljourneyrequest.Journeys[0].Segments[i].PaxSSRs = new PaxSSR[0]; } canceljourneyrequest.Journeys = booking.Journeys; CancelResponse cancelresponse = clientapi.Cancel(cancelrequest); Console.WriteLine("Balance Due after cancellation: {0:C}", cancelresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue); CommitRequest commitrequest = new CommitRequest(); commitrequest.BookingRequest = new CommitRequestData(); commitrequest.BookingRequest.Booking = new Booking(); commitrequest.BookingRequest.Booking.RecordLocator = booking.RecordLocator; commitrequest.BookingRequest.Booking.CurrencyCode = booking.CurrencyCode; commitrequest.BookingRequest.Booking.ReceivedBy = new ReceivedByInfo(); commitrequest.BookingRequest.Booking.ReceivedBy.ReceivedBy = "Michelle New"; commitrequest.Signature = signature; CommitResponse commitbookingresponse = clientapi.Commit(commitrequest); }
public void Delete(Booking entity) { if (HasPayments(entity)) { throw new BookingHasPaymentsException(); } _unitOfWork.BookingRepository.Delete(entity); _unitOfWork.Commit(); }
public EmailHistoryData(int email_history_id, int sms_and_email_type_id, int patient_id, int booking_id, string email, string message, DateTime datetime_sent) { this.email_history_id = email_history_id; this.sms_and_email_type = new IDandDescr(sms_and_email_type_id); this.patient = patient_id == -1 ? null : new Patient(patient_id); this.booking = booking_id == -1 ? null : new Booking(booking_id); this.email = email; this.message = message; this.datetime_sent = datetime_sent; }
public static Booking[] GetBetween(bool debugPageLoadTime, DateTime date_start, DateTime date_end, Staff[] staff, Organisation[] organisations, Patient patient, Staff added_by, bool incDeleted = false, string statusIDsToInclude = null, bool onlyUnavailabilities = false, string booking_id_serach = "") { DataTable tbl = GetDataTable_Between(debugPageLoadTime, date_start, date_end, staff, organisations, patient, added_by, incDeleted, statusIDsToInclude, onlyUnavailabilities, booking_id_serach); Booking[] bookings = new Booking[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) bookings[i] = LoadFull(tbl.Rows[i]); return bookings; }
public BaseFormBookingModel(Booking booking) { ProductFriendlyName = booking.Product.Name; BookingHint = booking.Product.BookingHint; BookingId = booking.Id; Date = booking.Date; StartTime = booking.StartTime.ToString(); EndTime = TimePart.EndTime(booking.StartTime, booking.Length).ToString(); Notes = Notes; }
protected void Page_Load(object sender, EventArgs e) { Booking booking = new Booking(); booking = (Booking)Session["BOOKING"]; LabelVehicle.Text = booking.IdVehicle.Id.ToString(); LabelNameParking.Text = booking.IdParkingLot.Name; LabelIdSpotOfPaking.Text = booking.IdParkingSpot.Id.ToString(); LabelinitialTime.Text = booking.EntryTime.ToString(); LabelFinalTime.Text = booking.ExitTime.ToString(); }
public override Room Read(Booking booking) { var room = DBConnection.ExecuteQuery( $"SELECT r.Id AS RoomId, Capacity FROM ConferenceRoom AS r "+ $"JOIN Booking ON r.Id = Booking.ConferenceRoomId "+ $"WHERE Booking.Id = {booking.Id};" ); return ParseToRoom(room).FirstOrDefault(); }
public void SendBookingNotificationIsSuccessful() { string responseData; var booking = new Booking { BusinessId = BUSINESS_ID, Guest = new Guest { Surname = "Test"}, BookingReferenceNumber = "12345", RoomTypeDescription = "Room-Type-Description", Id = BOOKING_ID, StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc) }; var bookingManager = new Mock<IBookingManager>(); bookingManager.Setup(b => b.GetByKey(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).Returns(booking); var pushGateway = new Mock<IPushNotificationGateway>(); pushGateway.Setup(p => p.SendPushNotification(It.IsAny<Notification>(), out responseData)).Returns(true); var dictionaryManager = new Mock<IDictionaryManager>(); dictionaryManager.Setup( x => x.GetDictionaryItemByKeysAndCultures( new List<string> { DictionaryConstants.PUSH_CREATEBOOKING_ALERT, DictionaryConstants.PUSH_CREATEBOOKING_TITLE }, It.IsAny<List<string>>())).Returns(new List<DictionaryDataItem> { new DictionaryDataItem {ItemKey = DictionaryConstants.PUSH_CREATEBOOKING_ALERT, DictionaryInstances = new Collection<DictionaryInstance>{ new DictionaryInstance{ Content = "hi"}}}, new DictionaryDataItem {ItemKey = DictionaryConstants.PUSH_CREATEBOOKING_TITLE, DictionaryInstances = new Collection<DictionaryInstance>{ new DictionaryInstance{ Content = "hi"}}} }); pushNotificationManager.PushNotificationGateway = pushGateway.Object; pushNotificationManager.BookingManager = bookingManager.Object; pushNotificationManager.DictionaryManager = dictionaryManager.Object; // Stub the BusinessCache to be used by our service method CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID); // invalidate the cache so we make sure our business is loaded into the cache Cache.Business.Invalidate(); pushNotificationManager.SendBookingNotification(BOOKING_ID, string.Empty); pushGateway.VerifyAll(); bookingManager.VerifyAll(); dictionaryManager.VerifyAll(); // Reassign the Dao on the cache to discard the stub assigned on the StubBusinessCacheSingleBusiness method CacheHelper.ReAssignBusinessDaoToBusinessCache(); }
public async Task<IHttpActionResult> PostBooking(Booking booking) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Bookings.Add(booking); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = booking.Id }, booking); }
public IHttpActionResult PostBooking(Booking booking) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Bookings.Add(booking); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = booking.Booking_id }, booking); }
public void ConfirmBooking_ManualMocking_SendCalledOnEmailService() { var mockedEmailService = new FakeEmailService(); var bookingComponent = new BookingComponent(mockedEmailService); var booking = new Booking(); var person = new Person(); bookingComponent.ConfirmBooking(booking, person); Assert.IsTrue(mockedEmailService.SendIsExecuted); }
public void ConfirmBooking_MockingThroughRhinoMocks_SendCalledOnEmailService() { var mockedEmailService = MockRepository.GenerateMock<IEmailService>(); var bookingComponent = new BookingComponent(mockedEmailService); var booking = new Booking(); var person = new Person(); bookingComponent.ConfirmBooking(booking, person); mockedEmailService.AssertWasCalled(service => service.Send(Arg<Email>.Is.Anything)); }
public ProcessBooking(Booking booking) { this.booking = booking; preAuthorisationState = new PreAuthorisationState(this); makeBookingState = new MakeBookingState(this); makePaymentState = new MakePaymentState(this); finalState = new FinalliseBookingState(this); initState = new InitialState(this); stateCurrent = initState; }
public Task AddBooking(Booking booking) { _context.Bookings.Add(booking); return(_context.SaveChangesAsync()); }
public async Task DeleteAsync(Booking booking) { booking.IsDeleted = true; await UpdateAsync(booking); }
public void Setup() { this.hotelController = new HotelController(); this.bookingController = new BookingController(); this.customerController = new CustomerController(); this.serviceController = new ServiceController(); this.roomTypeController = new RoomTypeController(); this.roomController = new RoomController(); this.billingController = new BillingEntityController(); this.pricingListController = new PricingListController(); this.hotel = new Hotel() { Name = "Alex Hotel", Address = "Syntagma", TaxId = "AH123456", Manager = "Alex", Phone = "2101234567", Email = "*****@*****.**" }; this.hotel = this.hotelController.CreateOrUpdateEntity(this.hotel); this.roomType = new RoomType() { Code = "TreeBed", View = View.MountainView, BedType = BedType.ModernCot, Tv = true, WiFi = true, Sauna = true }; this.roomType = this.roomTypeController.CreateOrUpdateEntity(this.roomType); this.room = new Room() { HotelId = this.hotel.Id, Code = "Alex Hotel 123", RoomTypeId = this.roomType.Id }; this.room = this.roomController.CreateOrUpdateEntity(this.room); this.service = new Service() { HotelId = this.hotel.Id, Code = "AHBF", Description = "Breakfast Alex Hotel" }; this.service = this.serviceController.CreateOrUpdateEntity(this.service); this.servicePricingList = new PricingList() { BillableEntityId = this.service.Id, TypeOfBillableEntity = TypeOfBillableEntity.Service, ValidFrom = DateTime.Now, ValidTo = Convert.ToDateTime("31/01/2017"), VatPrc = 13 }; this.servicePricingList = this.pricingListController.CreateOrUpdateEntity(this.servicePricingList); this.roomTypePricingList = new PricingList() { BillableEntityId = this.roomType.Id, TypeOfBillableEntity = TypeOfBillableEntity.RoomType, ValidFrom = DateTime.Now, ValidTo = Convert.ToDateTime("31/01/2017").Date, VatPrc = 13 }; this.roomTypePricingList = this.pricingListController.CreateOrUpdateEntity(this.roomTypePricingList); this.customer = new Customer() { Name = "Thodoris", Surname = "Kapiris", TaxId = "TK1234567", IdNumber = "AB1234567", Address = "Monasthraki", Email = "*****@*****.**", Phone = "2107654321" }; this.customer = this.customerController.CreateOrUpdateEntity(this.customer); this.booking = new Booking() { CustomerId = this.customer.Id, RoomId = this.room.Id, From = DateTime.Now, To = Convert.ToDateTime("31/01/2017"), SystemPrice = 12, AgreedPrice = 12, Status = Status.New, Comments = "Very good!!" }; this.booking = this.bookingController.CreateOrUpdateEntity(this.booking); this.billing = new Billing() { BookingId = this.booking.Id, PriceForRoom = this.booking.AgreedPrice, PriceForServices = 150, TotalPrice = 12150, Paid = true }; this.billing = this.billingController.CreateOrUpdateEntity(this.billing); }
public void BookingSaveOrUpdate(Booking booking) { BookingRepository.SaveOrUpdate(booking); }
public bool AddBookings(Booking booking) { throw new NotImplementedException(); }
public void ChosenBooking(object selectedBooking) { SelectBooking = (Booking)selectedBooking; }
public double TotalPriceOfBooking(Booking booking, Room room) { var TotalPrice = (booking.EndDate - booking.StartDate).TotalDays * (double)room.RoomPrice; return(TotalPrice); }
public async Task DeleteBookingAsync(Booking booking) { var httpClient = new System.Net.Http.HttpClient(); await httpClient.DeleteAsync(DeleteBookingUrl + booking.ID); }
static void Main(string[] args) { Booking[] bookings = new Booking[15]; int currentNumberOfElements = 0; int proceed = 1; while (proceed != 0) { DisplayMenu(); BookGuestHouse displayer = (BookGuestHouse)int.Parse(Console.ReadLine()); switch (displayer) { case BookGuestHouse.BookRoom: { Console.WriteLine("Enter YES if you would like to make a booking or No if you do not"); string Input = Console.ReadLine(); if (Input.ToLower() == "yes") { Booking currentBooking; for (int i = currentNumberOfElements; i < bookings.Length; i++) { Console.WriteLine("Please choose a type of room to book"); Console.WriteLine("1. Basic Room (R140)"); Console.WriteLine("2. Luxaurious (R400)"); string EnterInput = Console.ReadLine(); BookingType bookingType = BookingType.BasicRoom; if (EnterInput == "Basic Room" || EnterInput == "1") { bookingType = BookingType.BasicRoom; } else if (EnterInput == "Luxaurious" || EnterInput == "2") { bookingType = BookingType.Luxaurious; } Console.WriteLine("How many nights?(Enter numeral)"); uint numberOfNights = uint.Parse(Console.ReadLine()); Console.WriteLine("Would you like to recieve breakfast each morning Y/N"); string UserResponse = Console.ReadLine(); bool BreakfastFlag = false; if (UserResponse == "Y" || UserResponse == "y") { BreakfastFlag = true; } else if (UserResponse == "N" || UserResponse == "n") { BreakfastFlag = true; } bookings[i] = new Booking(bookingType, numberOfNights, BreakfastFlag); currentNumberOfElements++; Console.WriteLine("Would you like to continue Y/N"); string Response = Console.ReadLine(); if (Response == "N" || Response == "n") { break; } } if (currentNumberOfElements >= 14) { Console.WriteLine("All rooms are filled, try again later"); break; } } else { Console.WriteLine("Room not booked"); } } break; case BookGuestHouse.ViewCustomerTotals: { for (int i = 0; i < bookings.Length; i++) { if (bookings[i] == null) { continue; } else { Console.WriteLine("Booking: " + (i + 1) + " Total:" + bookings[i].total); } } } break; case BookGuestHouse.ViewBookingsMade: for (int i = 0; i < bookings.Length; i++) { if (bookings[i] == null) { continue; } else { Console.WriteLine("Booking: " + (i + 1) + "With Booking Data: " + bookings[i].ToString()); } } break; case BookGuestHouse.ViewCustomerThatWantBreafastService: for (int i = 0; i < bookings.Length; i++) { if (bookings[i] == null) { continue; } else if (bookings[i].BrealfastInTheMorning == true) { Console.WriteLine(bookings[i].ToString()); } } break; case BookGuestHouse.ViewGrandTotallOfAllBookings: double grandTotal = 0; foreach (var item in bookings) { if (item == null) { continue; } grandTotal += item.total; } break; case BookGuestHouse.ViewCustomerFromExpensiveAndLeastExpensive: Booking temp; for (int i = 0; i < bookings.Length; i++) { if (bookings[i] == null) { continue; } for (int j = 0; j < bookings.Length - 1; j++) { if (bookings[j] == null || bookings[j + 1] == null) { continue; } if (bookings[j].total > bookings[j + 1].total) { temp = bookings[j]; bookings[j] = bookings[j + 1]; bookings[j + 1] = temp; } } } break; case BookGuestHouse.Exit: Environment.Exit(0); break; default: break; } Console.WriteLine("would You like to contine press any number to continue and 0 to end"); proceed = int.Parse(Console.ReadLine()); } Console.ReadLine(); }
private void OnBookingFinished(Booking booking) { SetMenuItemStatus(MenuItemType.UpcomingRide, false); }
private void OnBookingRequested(Booking booking) { SetMenuItemStatus(MenuItemType.UpcomingRide, true); SetMenuItemStatus(MenuItemType.ReportIncident, true); }
public BookingVM(Booking booking) { _booking = booking; Discounts = new List <Discount>(); }
public int CalculateBookingCost(int roomId, Booking booking) { return(0); }
public void DeleteBooking(Booking booking) { _context.Bookings.Remove(booking); _context.SaveChanges(); }
private void SendEmailToDriver(Booking booking) { string message = $"Dear {booking.Ride.Car.AppUser.FirstName}, You have a new booking by {booking.AppUser.UserName} for the ride on {booking.Ride.StartTime} from {booking.Ride.DepartureLocation} to {booking.Ride.DestinationLocation}. Best regards. Your Zpool-Team"; _emailSender.SendEmailAsync(booking.Ride.Car.AppUser.Email, "New booking", message); }
///// <summary> ///// Inserts into database the booking for air travel ///// </summary> ///// <param name="newBooking"></param> ///// <param name="dbConnection"></param> ///// <exception cref="AirTravelBookingException">Throws the AirTravelBookingException, if unable to store a booking</exception> ///// <returns>Returns the booking reference number</returns> //public string MakeBooking(Booking newBooking, Database dbConnection) //{ // string bookingReferenceNo = string.Empty; // //Downcast to flight booking // FlightBooking airBooking = (FlightBooking)newBooking; // try // { // //Write code to store data into database // DbCommand command = dbConnection.GetStoredProcCommand("BookFlightTicket"); // dbConnection.AddInParameter(command, "@TypeID", DbType.Int32, (int)airBooking.BookingType); // dbConnection.AddInParameter(command, "@DateOfJourney", DbType.DateTime, airBooking.DateOfJourney); // dbConnection.AddInParameter(command, "@NoOfSeats", DbType.Int32, airBooking.NoOfSeats); // dbConnection.AddInParameter(command, "@ClassID", DbType.Int32, (int)airBooking.Class.ClassInfo); // dbConnection.AddInParameter(command, "@ContactName", DbType.String, airBooking.Contact.ContactName); // dbConnection.AddInParameter(command, "@Address", DbType.String, airBooking.Contact.Address); // dbConnection.AddInParameter(command, "@City", DbType.String, airBooking.Contact.City); // dbConnection.AddInParameter(command, "@State", DbType.String, airBooking.Contact.State); // dbConnection.AddInParameter(command, "@PinCode", DbType.String, airBooking.Contact.PinCode); // dbConnection.AddInParameter(command, "@Email", DbType.String, airBooking.Contact.Email); // dbConnection.AddInParameter(command, "@PhoneNo", DbType.String, airBooking.Contact.PhoneNo); // dbConnection.AddInParameter(command, "@MobileNo", DbType.String, airBooking.Contact.MobileNo); // dbConnection.AddInParameter(command, "@PaymentRefernceNo", DbType.String, airBooking.PaymentInfo.ReferenceNo); // dbConnection.AddInParameter(command, "@TotalCost", DbType.Decimal, airBooking.TotalCost); // //Concatenate to send to database as a single string // string passengerDetails = String.Empty; // string name = String.Empty; // string gender = String.Empty; // string dob = String.Empty; // foreach (Passenger p in airBooking.GetPassengers()) // { // name = p.Name; // gender = p.Gender.ToString(); // dob = p.DateOfBirth.ToShortDateString(); // passengerDetails = name + "|" + gender + "|" + dob + ";"; // } // dbConnection.AddInParameter(command, "@PassengerDetails", DbType.String, passengerDetails); // dbConnection.AddOutParameter(command, "@BookingReferenceNumber", DbType.String, 100); // dbConnection.AddOutParameter(command, "@LastBookingID", DbType.Int64, 0); // //Execute the command // dbConnection.ExecuteNonQuery(command); // //Get the values from the database // bookingReferenceNo = dbConnection.GetParameterValue(command, "@BookingReferenceNumber").ToString(); // long bookingId = Convert.ToInt64(dbConnection.GetParameterValue(command, "@LastBookingID")); // //Insert the schedules for a booking // foreach (Schedule s in airBooking.TravelScheduleInfo.GetSchedules()) // { // try // { // InsertBookingSchedule(bookingId, s.ID, s.GetFlightCosts().FirstOrDefault().CostPerTicket, dbConnection); // } // catch (AirTravelBookingException) // { // throw; // } // } // } // catch(AirTravelBookingException) // { // throw; // } // catch (DbException ex) // { // throw new AirTravelBookingException("Unable to insert air travel booking", ex); // } // catch (Exception ex) // { // throw new AirTravelBookingException("Unable to insert air travel booking", ex); // } // return bookingReferenceNo; //} ///// <summary> ///// Inserts the schedule for a booking ///// </summary> ///// <param name="bookingId"></param> ///// <param name="scheduleId"></param> ///// <param name="costPerTicket"></param> ///// <param name="dbConnection"></param> ///// <returns></returns> //private bool InsertBookingSchedule(long bookingId, long scheduleId, decimal costPerTicket, Database dbConnection) //{ // bool isStored = false; // try // { // //Write code to store data into database // DbCommand command = dbConnection.GetStoredProcCommand("InsertFlightTicketSchedule"); // dbConnection.AddInParameter(command, "@BookingId", DbType.Int64, bookingId); // dbConnection.AddInParameter(command, "@ScheduleId", DbType.Int64, scheduleId); // dbConnection.AddInParameter(command, "@CostPerTicket", DbType.Decimal, costPerTicket); // //Execute the command // dbConnection.ExecuteNonQuery(command); // isStored = true; // } // catch (DbException ex) // { // throw new AirTravelBookingException("Unable to insert air travel schedule", ex); // } // catch (Exception ex) // { // throw new AirTravelBookingException("Unable to insert air travel schedule", ex); // } // return isStored; //} #endregion #region Method to store booking details for an air travel /// <summary> /// Inserts into database the booking for air travel /// </summary> /// <param name="newBooking"></param> /// <param name="dbConnection"></param> /// <exception cref="AirTravelBookingException">Throws the AirTravelBookingException, if unable to store a booking</exception> /// <returns>Returns the booking reference number</returns> public string MakeBooking(Booking newBooking, IDbConnection dbConnection) { string bookingReferenceNo = string.Empty; //Downcast to flight booking FlightBooking airBooking = (FlightBooking)newBooking; try { dbConnection.Open(); IDbCommand cmd = dbConnection.CreateCommand(); cmd.CommandText = "BookFlightTicket"; cmd.CommandType = CommandType.StoredProcedure; IDbDataParameter p1 = cmd.CreateParameter(); p1.ParameterName = "@TypeID"; p1.Value = (int)airBooking.BookingType; cmd.Parameters.Add(p1); IDbDataParameter p2 = cmd.CreateParameter(); p2.ParameterName = "@DateOfJourney"; p2.Value = airBooking.DateOfJourney; cmd.Parameters.Add(p2); IDbDataParameter p3 = cmd.CreateParameter(); p3.ParameterName = "@NoOfSeats"; p3.Value = airBooking.NoOfSeats; cmd.Parameters.Add(p3); IDbDataParameter p4 = cmd.CreateParameter(); p4.ParameterName = "@ClassID"; p4.Value = (int)airBooking.Class.ClassInfo; cmd.Parameters.Add(p4); IDbDataParameter p5 = cmd.CreateParameter(); p5.ParameterName = "@ContactName"; p5.Value = airBooking.Contact.ContactName; cmd.Parameters.Add(p5); IDbDataParameter p6 = cmd.CreateParameter(); p6.ParameterName = "@Address"; p6.Value = airBooking.Contact.Address; cmd.Parameters.Add(p6); IDbDataParameter p7 = cmd.CreateParameter(); p7.ParameterName = "@City"; p7.Value = airBooking.Contact.City; cmd.Parameters.Add(p7); IDbDataParameter p8 = cmd.CreateParameter(); p8.ParameterName = "@State"; p8.Value = airBooking.Contact.State; cmd.Parameters.Add(p8); IDbDataParameter p9 = cmd.CreateParameter(); p9.ParameterName = "@PinCode"; p9.Value = "000000"; cmd.Parameters.Add(p9); IDbDataParameter p10 = cmd.CreateParameter(); p10.ParameterName = "@Email"; p10.Value = airBooking.Contact.Email; cmd.Parameters.Add(p10); IDbDataParameter p11 = cmd.CreateParameter(); p11.ParameterName = "@PhoneNo"; p11.Value = airBooking.Contact.PhoneNo; cmd.Parameters.Add(p11); IDbDataParameter p12 = cmd.CreateParameter(); p12.ParameterName = "@MobileNo"; p12.Value = airBooking.Contact.MobileNo; cmd.Parameters.Add(p12); IDbDataParameter p13 = cmd.CreateParameter(); p13.ParameterName = "@PaymentRefernceNo"; p13.Value = airBooking.PaymentInfo.ReferenceNo; cmd.Parameters.Add(p13); IDbDataParameter p14 = cmd.CreateParameter(); p14.ParameterName = "@TotalCost"; p14.Value = airBooking.TotalCost; cmd.Parameters.Add(p14); //Concatenate to send to database as a single string string passengerDetails = String.Empty; string name = String.Empty; string gender = String.Empty; string dob = String.Empty; foreach (Passenger p in airBooking.GetPassengers()) { name = p.Name; gender = p.Gender.ToString(); dob = p.DateOfBirth.ToShortDateString(); passengerDetails += name + "|" + gender + "|" + dob + ";"; } IDbDataParameter p15 = cmd.CreateParameter(); p15.ParameterName = "@PassengerDetails"; p15.Value = passengerDetails; cmd.Parameters.Add(p15); IDbDataParameter bookingRefNo = cmd.CreateParameter(); bookingRefNo.Size = -1; bookingRefNo.ParameterName = "@BookingReferenceNumber"; bookingRefNo.Direction = ParameterDirection.Output; bookingRefNo.Value = ""; cmd.Parameters.Add(bookingRefNo); IDbDataParameter lastBookingId = cmd.CreateParameter(); lastBookingId.ParameterName = "@LastBookingID"; lastBookingId.Direction = ParameterDirection.Output; lastBookingId.Value = 0; cmd.Parameters.Add(lastBookingId); //Execute the command cmd.ExecuteNonQuery(); //Get the values from the database bookingReferenceNo = bookingRefNo.Value.ToString(); long bookingId = Convert.ToInt64(lastBookingId.Value); //Insert the schedules for a booking foreach (Schedule s in airBooking.TravelScheduleInfo.GetSchedules()) { try { InsertBookingSchedule(bookingId, s.ID, s.GetFlightCosts().FirstOrDefault().CostPerTicket, dbConnection); } catch (AirTravelBookingException) { throw; } } } catch (AirTravelBookingException) { throw; } catch (DbException ex) { throw new AirTravelBookingException("Unable to insert air travel booking", ex); } catch (Exception ex) { throw new AirTravelBookingException("Unable to insert air travel booking", ex); } finally { if (dbConnection != null && dbConnection.State == ConnectionState.Open) { dbConnection.Close(); } } return(bookingReferenceNo); }
private void TicketsFree(object sender, RoutedEventArgs e) { Booking booking = (Booking)bookingsGrid.SelectedItem; DeleteOrder(booking); MessageBox.Show("Заказ отменен."); }
static SlimBookingConfirmation ConvertToSlimBookingConfirmation(Booking booking) => new()
public static void Main(string[] args) { User user = new User(); Information information = new Information(); InformationServices informationServies = new InformationServices(); RideServices rideServices = new RideServices(); UserServices userServices = new UserServices(); VehicleServices vehicleServices = new VehicleServices(); BookingServices bookingServices = new BookingServices(); ValidationServices validationServices = new ValidationServices(); Dsiplayervices display = new Dsiplayervices(); HelperMethods helperMethods = new HelperMethods(); List <Ride> rides = new List <Ride>(); List <Vehicle> vehicles = new List <Vehicle>(); int option; display.Print("Welcome to Carpool Application"); while (true) { display.Print("Choose an Option:\n\t1.Login\n\t2.Signup\n................................\nselect an option: "); option = helperMethods.Option(); switch (option) { case 1: while (true) { while (true) { string id; display.Print("Please enter login id: "); string loginId = display.Scan(); display.Print("Please enter the password: "******"Choose an option\n\t1.Riding Services\n\t2.Booking Services\n\t3.View Profile\n\t4.Logout\n................................................\nSelect an option: "); option = helperMethods.Option(); switch (option) { case 1: display.Print("Choose an option\n\t1.Create a Ride(please add a car in view profile before ctreating)\n\t2.Approve requests\n\t3.Add Viapoints\n\t4.go back\n................................................\nSelect an option: "); option = helperMethods.Option(); switch (option) { case 1: { bool state; Ride ride = new Ride(); display.Print("please enter the details Ride creation:"); display.Print("................................................."); display.Print("Your Vehicles"); vehicles = vehicleServices.View(user.Vehicles, id); while (true) { display.Print("Your Vehicles"); foreach (Vehicle vehicle in vehicles) { Console.WriteLine($"{vehicle.Type}"); } display.Print("please enter the vehicle choosed"); string vehicleName = display.Scan(); ride.Vehicle = user.Vehicles.Find(a => a.Type == vehicleName); try { state = string.IsNullOrEmpty(ride.Vehicle.Type); } catch (NullReferenceException) { state = true; } if (state == false) { break; } else { display.Print("the vehicle is not present in your List"); continue; } } ride.UserID = user.UserID; while (true) { display.Print("Please enter price for km:"); try { ride.Priceperkm = int.Parse(display.Scan()); break; } catch (FormatException) { display.Print("Check format of price"); } } display.Print(".........................."); display.Print("please enter the details for starting Address:"); helperMethods.ScanAddress(ride.StartAddress); display.Print(".........................."); display.Print("please enter the details for Destination Address:"); helperMethods.ScanAddress(ride.Destination); display.Print(".........................."); ride.Price = Convert.ToString(helperMethods.PriceEstimattion(ride)); Console.WriteLine("end to end price of ride is: {0}", ride.Price); display.Print(".........................."); ride.RideID = rideServices.GenerateRideId(user.Name); Console.WriteLine("the generated ride Id is {0}", ride.RideID); while (true) { display.Print("enter the date and time of departure in the form of dd/mm/yyyy HH:MM:"); while (true) { try { ride.DepartureTime = DateTime.Parse(display.Scan()); break; } catch (System.FormatException) { display.Print("Please check format"); continue; } } if (validationServices.Time(Convert.ToString(ride.DepartureTime)) == true) { break; } else { Console.WriteLine("please enter the date format as HH:MM"); continue; } } while (true) { display.Print("Do you want to add via points\n1.Yes\n2.No"); option = helperMethods.Option(); switch (option) { case 1: display.Print(".........................."); display.Print("enter details for via point creation"); helperMethods.ScanAddress(ride.Destination); display.Print("..................................."); ride.Price = Convert.ToString(helperMethods.PriceEstimattion(ride)); Console.WriteLine("end to end price of ride is{0}", ride.Price); ride.ListofViaPoints.Add(ride.ViaPoint); display.Print("a via point is created"); continue; case 2: break; default: display.Print("invalid opton"); continue; } break; } rideServices.Create(id, information, ride); display.Print("a Ride is created\n....................."); } break; case 2: { string rideId; rides = userServices.ViewRides(information, id); if (rides != null) { foreach (Ride ThisRide in rides) { if (ThisRide.DepartureTime > DateTime.Now) { Console.WriteLine($"{ThisRide.RideID} {ThisRide.StartAddress.Location} {ThisRide.Destination.Location} {ThisRide.DepartureTime}"); } } display.Print(".............................."); display.Print("please enter a valid ride id"); rideId = display.Scan(); Ride ride = rides.Find(SelectedRide => SelectedRide.RideID == rideId); List <Booking> bookings = rideServices.ViewBookingRequest(ride); if (bookings != null) { foreach (Booking booking in bookings) { Console.WriteLine($"{booking.BookingId} {booking.FromAddress.Location} {booking.ToAddress.Location} {booking.SeatsRequired}"); } display.Print("please enter a valid booking id"); string bookingId = display.Scan(); try { Booking booking = user.Bookings.Find(SelectedBooking => SelectedBooking.BookingId == bookingId); } catch (NullReferenceException) { display.Print("booking request is invalid \n......................."); } display.Print("do you want to approve request?\n\t1.Yes\n\t2.No\n\t3.May be Later"); rideServices.Approve(bookingId, id, rideId, information); Console.WriteLine("the Changes are done to the Request!!!!!!!!"); display.Print("................................"); break; } else { Console.WriteLine("NO BOOKINGS YET!!!!"); Console.WriteLine("..........................."); break; } } else { display.Print("The Ride list is empty"); break; } } default: continue; } break; case 2: { while (true) { display.Print("Choose an option\n\t1.find a Ride\n\t2.Booking status\n\t3.go back\n................................................\nSelect an option: "); try { option = int.Parse(display.Scan()); break; } catch (FormatException) { display.Print("Check format of option"); } } switch (option) { case 1: Booking booking = new Booking(); booking.UserID = user.UserID; booking.BookingId = bookingServices.GenerateBooking(user.Name); display.Print(".........................."); display.Print("please enter the details for satrting Address:"); helperMethods.ScanAddress(booking.FromAddress); display.Print(".........................."); display.Print("please enter the details for Destination Address:"); helperMethods.ScanAddress(booking.ToAddress); while (true) { display.Print("Please enter number of seats required"); try { booking.SeatsRequired = int.Parse(display.Scan()); break; } catch (FormatException) { display.Print("Check format of distance"); } } display.Print(".........................."); display.Print("The Rides available are:"); bool isValid = false; rides = informationServies.ViewAvailableRides(information, booking, isValid); foreach (Ride ride in rides) { Console.WriteLine($"{ride.RideID} {ride.DepartureTime}{ride.StartAddress.Location}{ride.Destination.Location}"); } display.Print("please selecte a ride by rideId :"); string rideId = display.Scan(); Ride SelectedRide = information.Rides.Find(ride => ride.RideID == rideId); if (SelectedRide != null) { SelectedRide.Bookings.Add(booking); user.Bookings.Add(booking); display.Print("a booking Request is sent"); } break; case 2: List <Booking> bookings = userServices.ViewBookings(id); if (bookings != null) { foreach (Booking Thisbooking in bookings) { Console.WriteLine($"{Thisbooking.BookingId} {Thisbooking.FromAddress.Location} {Thisbooking.ToAddress.Location} {Thisbooking.Approval}"); } break; } else { Console.WriteLine("NO BOOKINGS YET!!!!"); Console.WriteLine("..........................."); break; } default: break; } } break; case 3: display.Print("Choose an option\n\t1.Update vehicle list\n\t2.view my vehicle list\n\t3.Display my offers\n\t4.Display my bookingsgs \nPlease select a option "); option = helperMethods.Option(); switch (option) { case 1: display.Print("please select a option:\n1.Add a vehicle.\n2.Remove a vehicle"); option = helperMethods.Option(); switch (option) { case 1: display.Print("Please enter car type: "); string carType = display.Scan(); display.Print("Please enter no of seats: "); int seatsnumber = int.Parse(display.Scan()); vehicleServices.Create(user.Vehicles); display.Print("the car is added to the list "); display.Print("............................"); break; case 2: display.Print("Please enter car type: "); string vehicleType = display.Scan(); vehicleServices.Delete(vehicleType, user.Vehicles); display.Print("the car is reemoved from the list "); display.Print("............................"); break; default: display.Print("inavlid option\n.........................."); continue; } break; case 2: vehicles = userServices.ViewVehicles(id); if (vehicles != null) { foreach (Vehicle vehicle in vehicles) { Console.WriteLine($"{vehicle.Type}"); } display.Print("............................"); break; } else { display.Print("the vehicle list is empty!!!!"); break; } case 3: rides = userServices.ViewRides(information, id); if (rides != null) { foreach (Ride ThisRide in rides) { if (ThisRide.DepartureTime > DateTime.Now) { Console.WriteLine($"{ThisRide.RideID} {ThisRide.StartAddress.Location} {ThisRide.Destination.Location} {ThisRide.DepartureTime}"); } } display.Print(".............................."); break; } else { display.Print("The Ride list is empty"); break; } case 4: List <Booking> bookings = userServices.ViewBookings(id); if (bookings != null) { foreach (Booking booking in user.Bookings) { Console.WriteLine($"{booking.BookingId} {booking.UserID} {booking.FromAddress} {booking.ToAddress} {booking.SeatsRequired} "); } display.Print("............................"); break; } else { display.Print("The Booking List is empty"); break; } default: display.Print("inavlid option\n.........................."); continue; } break; case 4: { while (true) { display.Print("Do you want to log out?\n1.yes\n2.No\n"); option = helperMethods.Option(); switch (option) { case 1: isLoggedOut = informationServies.LogOut(); user = null; display.Print("Logged out\n.................................................."); break; case 2: break; default: display.Print("enter a valid option"); continue; } break; } } break; default: break; } if (isLoggedOut == true) { break; } else { continue; } } break; } else { display.Print("Please enter valid details\n....................................\n"); break; } } break; } break; case 2: User CreatedUser = new User(); display.Print("Please enter login id: "); CreatedUser.UserID = display.Scan(); display.Print("Please enter the password: "******"...................................................."); display.Print("Please enter name: "); CreatedUser.Name = display.Scan(); while (true) { display.Print("Please enter phoone: "); CreatedUser.PhoneNo = display.Scan(); if (validationServices.Phone(CreatedUser.PhoneNo) == true) { break; } else { Console.WriteLine("please enter the correct format"); continue; } } display.Print("Please enter occupation: "); CreatedUser.Occupation = display.Scan(); display.Print("Please enter mail: "); CreatedUser.Mail = display.Scan(); userServices.Create(CreatedUser.UserID, CreatedUser.Password, CreatedUser.Name, CreatedUser.PhoneNo, CreatedUser.Occupation, CreatedUser.Mail); display.Print("User has been successfully created\n......................................"); break; default: display.Print("Unavailable option\n............................................."); break; } } }
public ActionResult Details(Guid id) { Booking booking = db.Bookings.Single(b => b.id == id); return(View(booking)); }
public bool UpdateBookings(int id, Booking booking) { throw new NotImplementedException(); }
public void EditBooking(Booking booking) { _context.Bookings.Update(booking); _context.SaveChanges(); }
public IQueryOver <BookingBusByDate, BookingBusByDate> BookingBusByDateGetAllByCriterion(Booking booking) { return(BookingBusByDateRepository.BookingBusByDateGetAllByCriterion(booking, null)); }
public async Task UpdateAsync(Booking booking) { _context.Entry(booking).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public Book(Booking booking) : base(booking) { }
/// <summary> /// Called when the user clicks the Save button. Parses the controls in the EditView to an IModel and saves/updates it in the database /// </summary> /// <param name="oldIdentifyingAttributes">If the IModel has changed their identifying attribute, these are the old/current identifying attributes</param> public void HandleSaveButtonClick(Dictionary <string, object> oldIdentifyingAttributes = null) { if (this.IdentifyingValuesAreNotEmpty()) { IModel model = null; var controlValues = this.ViewControlsToDictionary(EditView.GetControls()); if (controlValues != null) { model = Utils.ParseWinFormsToIModel(EditView.Model, controlValues, QueryType.ADD); if (model != null && model.GetIdentifyingAttributes().First().Value != null) { if (model is Building) { DateTime opening, closing; opening = ((Building)model).Avail_start; closing = ((Building)model).Avail_end; if (opening > closing) { this.UpdateResponseLabel("Öppningstid kan inte vara senare än stängningstid"); return; } } //Special case for booking, since it cannot overlap another booking //But if it's an update to an existing item, we're not doing the check if (model is Booking) { Booking parsedBooking = (Booking)model; if (parsedBooking.RoomId == null || parsedBooking.PersonId == null || parsedBooking.Start_time == default(DateTime) || parsedBooking.End_time == default(DateTime)) { this.UpdateResponseLabel("Något av följande fält är tomt, vänligen fyll i alla obligatoriska fält (Person, Rum, Starttid, Sluttid"); return; } if (isExistingObjectInDatabase == false) { DAL d = new DAL(this); bool isBookable = d.IsRoomBookableOnDate(parsedBooking.RoomId, parsedBooking.Start_time, parsedBooking.End_time); if (isBookable == false) { this.UpdateResponseLabel("Rummet är redan bokad denna tid, vänligen välj en annan"); return; } } DateTime startDate = parsedBooking.Start_time; DateTime endDate = parsedBooking.End_time; startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 0, 0); endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, endDate.Hour, 0, 0); ((Booking)model).Start_time = startDate; ((Booking)model).End_time = endDate; } // SAVING OBJECT DAL dal = new DAL(this); int affectedRows = 0; string dbMethod = ""; if (isExistingObjectInDatabase) { if (oldIdentifyingAttributes != null && oldIdentifyingAttributes.Count > 0) { affectedRows = dal.Update(model, oldIdentifyingAttributes); } else { affectedRows = dal.Update(model); } dbMethod = "uppdaterad"; } else { affectedRows = dal.Add(model); dbMethod = "tillagd"; } string displayName = Utils.ConvertAttributeNameToDisplayName(model, model.GetType().Name); displayName = displayName[0].ToString().ToUpper() + displayName.Substring(1); if (affectedRows > 0) { this.UpdateResponseLabel(string.Format("{0} {1}", displayName, dbMethod)); this.isExistingObjectInDatabase = true; this.SetAllControlsDisabledExceptClose(); } else if (affectedRows != -1) { //-1 is error from DAL this.UpdateResponseLabel(string.Format("Ingen {0} {1}", displayName, dbMethod)); } // END OF SAVING if (affectedRows > 0 && this.ViewHasListOfIModels) { // Foreach the keys in the originalvalues (there can be multiple lists/checklistboxes) foreach (var changedStatusForType in this.changedStatusOnReferencingModels) { Type referencedType = changedStatusForType.Key; Dictionary <IModel, bool> changedStatus = changedStatusForType.Value; Dictionary <IModel, bool> initialStatus = this.InitialStatusOnReferencingModels.ContainsKey(referencedType) ? this.InitialStatusOnReferencingModels[referencedType] : null; List <IModel> toBeAdded = new List <IModel>(); List <IModel> toDeleteOrUpdateToNull = new List <IModel>(); bool doOrdinaryAddAndDelete = false; var intersected = initialStatus.Keys.Intersect(changedStatus.Keys).ToList(); foreach (var intersectedModel in intersected) { if (initialStatus[intersectedModel] == true && changedStatus[intersectedModel] == false) { toDeleteOrUpdateToNull.Add(intersectedModel); } else if (initialStatus[intersectedModel] == false && changedStatus[intersectedModel] == true) { toBeAdded.Add(intersectedModel); } } // If it's an associationtable, and a changedStatus-dict contains elements // delete all associated-table-objects with ID from each IDs if (model is Room && changedStatus.Any() && changedStatus.First().Key is Resource) { toBeAdded = toBeAdded.Select(x => (IModel) new Room_Resource(((Room)model).Id, ((Resource)x).Id)).ToList(); toDeleteOrUpdateToNull = toDeleteOrUpdateToNull.Select(x => (IModel) new Room_Resource(((Room)model).Id, ((Resource)x).Id)).ToList(); doOrdinaryAddAndDelete = true; } dal = new DAL(this); int added = 0, updatedOrRemoved = 0; if (doOrdinaryAddAndDelete && (toBeAdded.Any() || toDeleteOrUpdateToNull.Any())) { foreach (IModel add in toBeAdded) { added += dal.Add(add); } foreach (IModel remove in toDeleteOrUpdateToNull) { updatedOrRemoved += dal.Remove(remove); } } else if (!doOrdinaryAddAndDelete) { if (toBeAdded.Any()) { added = dal.ConnectOrNullReferencedIModelsToIModelToQuery(toBeAdded, model, true); } if (toDeleteOrUpdateToNull.Any()) { updatedOrRemoved = dal.ConnectOrNullReferencedIModelsToIModelToQuery(toDeleteOrUpdateToNull, model, false); } } } } } else { this.UpdateResponseLabel(string.Format("Identifierande attribut ({0}) kan ej vara tomt", string.Join(", ", this.identifyingAttributesValues.Keys))); } } } }
public void Delete(Booking booking) { booking.IsDeleted = true; Update(booking); }
private void Save(Booking store) { _bookingrepository.Save(store); }
private void update(Booking store) { _bookingrepository.Update(store); }
public async Task Initialize(Booking booking) { _booking.State = booking; await _booking.WriteStateAsync(); }