public IActionResult Booking(int id, DateTime date, DateTime time, int hour) { if (!string.IsNullOrEmpty(HttpContext.Session.GetString("Token"))) { var steam = HttpContext.Session.GetString("Token"); var tokens = new JwtSecurityTokenHandler().ReadJwtToken(steam); var userId = tokens.Claims.First(claim => claim.Type == "Id").Value; var userRole = tokens.Claims.First(claim => claim.Type == "role").Value; //check blacklist user if (userRole == "Blacklist") { return(RedirectToAction("Index", "Home")); } //insert record to database BookingList booking = new BookingList(); booking.UserId = userId; booking.EqId = id; booking.Date = date.AddHours(time.Hour); booking.Time = hour; Console.WriteLine(date); _db.BookingList.Add(booking); _db.SaveChanges(); return(Redirect("/Book/?id=" + Convert.ToString(id))); } return(RedirectToAction("Index", "Home")); }
//Tar bort bokning public string RemoveBooking(string apartmentNr) { string message = ""; try { List <BookingList> bookingList = con.BookingList.Where(r => r.apartmentNr == apartmentNr).ToList(); if (bookingList.Count() != 0) { BookingList a = con.BookingList.First(r => r.apartmentNr == apartmentNr); con.BookingList.Remove(a); con.SaveChanges(); message = "Meddelande: Bokningen borttagen!"; return(message); } message = "Meddelande: Borttagningen misslyckades, ingen bokning existerar!"; return(message); } catch (InvalidOperationException) { throw new DatabaseException("Databasfel, kontakta systemadminstratör"); } }
public BokaStuga() { InitializeComponent(); try { cabinList = ServiceProvider.GetCabinService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { customerList = ServiceProvider.GetCustomerService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { bookingList = ServiceProvider.GetBookingService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } initListView(); lvwBokaKund.HideSelection = false; lvwBokaStuga.HideSelection = false; }
public Surveys GetById(long id) { var survey = GetAll().FirstOrDefault(h => h.Id == id); if (survey != null) { var customerId = BookingList.First(x => x.BookingId == survey.BookingId).CustomerId; var hotels = (from h in HotelList join p in ProductList on h.HotelId equals p.HotelId join b in BookingList on p.ProductId equals b.ProductId where b.BookingId == survey.BookingId select h).FirstOrDefault(); var products = (from p in ProductList join b in BookingList on p.ProductId equals b.ProductId where b.BookingId == survey.BookingId select p).FirstOrDefault(); var bookings = BookingList.FirstOrDefault(b => b.BookingId == survey.BookingId); survey.TicketPurchased = BookingList.Where(b => b.CustomerId == customerId).Sum(b => b.Quantity); survey.HotelName = hotels != null ? hotels.HotelName : string.Empty; survey.City = hotels != null ? hotels.City : string.Empty; survey.ProductName = products != null ? products.ProductName : string.Empty; survey.CheckInDate = bookings != null ? bookings.CheckinDate : null; survey.PerTicketPrice = bookings != null ? bookings.HotelPrice : 0; survey.TotalPrice = bookings != null ? bookings.TotalPrice : 0; } return(survey); }
public Surveys GetSurveysByCode(string code) { var surveys = GetAll().FirstOrDefault(x => x.Code == code); if (surveys != null) { var booking = BookingList.FirstOrDefault(b => b.BookingId == surveys.BookingId); if (booking != null) { var product = ProductList.FirstOrDefault(p => p.ProductId == booking.ProductId); surveys.RedeemedDate = booking.RedeemedDate; surveys.HotelPrice = booking.HotelPrice; if (product != null) { var hotel = HotelList.FirstOrDefault(h => h.HotelId == product.HotelId); string imageUrl = Constant.ImageDefault; var image = ProductImageList.FirstOrDefault(x => x.ProductId == product.ProductId && x.IsCover && x.IsActive); if (image != null) { imageUrl = image.Url; } surveys.ImageUrl = imageUrl; if (hotel != null) { surveys.HotelInfo = string.Format("{0} at {1}<br/> {2}, {3}", product.ProductName, hotel.HotelName, hotel.Neighborhood, hotel.City); } } } } return(surveys); }
public async Task AllBookings() { var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId); customer = customerID; var request = new BookingSearchRequest { CustomerID = customer.CustomerId }; BookingList.Clear(); var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request); foreach (var item in list) { item.EndDate = item.EndDate.AddHours(8).Date; BookingList.Add(item); } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "You don't have any bookings yet.", "OK"); } }
public async Task <IActionResult> Edit(int id, [Bind("BookingListId,BookingTime,CustomerId,FirstName,LastName,Address,City,Province,PostalCode,Phone,email,Total")] BookingList bookingList) { if (id != bookingList.BookingListId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bookingList); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingListExists(bookingList.BookingListId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bookingList)); }
public async Task Initialization() { var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId); customer = customerID; var request = new BookingSearchRequest { CustomerID = customer.CustomerId }; BookingList.Clear(); var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request); foreach (var item in list) { if (item.RatingStatus == false && item.EndDate.Date <= DateTime.Now.Date) { BookingList.Add(item); } } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "The list is empty. You can leave a rating on the reserved vehicle after the reservation expires or you have not booked yet. Please, try again later.", "OK"); } }
private void CreateMiscList(string name, bool IsMisc) { var list = new BookingList(name); list.Occurrence = _occ; list.IsMisc = IsMisc; _lists.Add(list); _globalMiscList = list; }
private void LoadBookings() { BookingList.Clear(); IEnumerable <Booking> bookings = repository.GetBookings(); foreach (Booking item in bookings) { BookingList.Add(item); } }
public void Init() { if (Student != null) { switch (BookingType) { case BookingType.green: { _myBookingList = BookingLists.FirstOrDefault(); break; } case BookingType.yellow: { var list = BookingLists.FirstOrDefault(x => x.Curricula.Any(c => c.Id == Student.Curriculum.Id)); if (list != null) { _myBookingList = list; } else { _myBookingList = BookingLists.FirstOrDefault(x => !x.Curricula.Any()); } break; } case BookingType.red: { _myBookingList = BookingLists.FirstOrDefault(x => x.Curricula.Any(c => c.Id == Student.Curriculum.Id)); break; } } } if (!Occurrence.IsAvailable) { IsAvailable = false; Reasons.Add("Eintragung ist von Admin-Seite aus gesperrt worden."); } if (BookingType == BookingType.red && _myBookingList == null) { IsAvailable = false; Reasons.Add("Diese Lehrveranstaltung steht für meinen Studiengang nicht zur Verfügung."); } if (_myBookingList != null && _myBookingList.Capacity >= 0) { IsUnrestricted = false; AvailableSeats = _myBookingList.Capacity - _myBookingList.Participients.Count; } }
public async Task <IActionResult> Create([Bind("BookingListId,BookingTime,CustomerId,FirstName,LastName,Address,City,Province,PostalCode,Phone,email,Total")] BookingList bookingList) { if (ModelState.IsValid) { _context.Add(bookingList); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bookingList)); }
/// <summary> /// Removes the booking from the BookingList /// </summary> /// <param name="id"></param> public void RemoveBookingFromList(int id) { if (id > 0) { var tempBooking = BookingList.SingleOrDefault(x => x.BookingId == id); if (tempBooking != null) { BookingList.Remove(tempBooking); } } }
/// <summary> /// Saves all bookings on the BookingList to the database /// </summary> public void SaveBookingsToDB() { foreach (var booking in BookingList) { int bookingId = Bookings.Insert(booking); foreach (var item in booking.Credits.OrderBy(x => x.CreditId)) { item.RefBookingId = bookingId; var fakeId = item.CreditId; item.CreditId = Credits.Insert(item); foreach (var credit in booking.Credits) { if (credit.RefCreditId == fakeId) { credit.RefCreditId = item.CreditId; } } } foreach (var item in booking.Debits.OrderBy(x => x.DebitId)) { item.RefBookingId = bookingId; var fakeId = item.DebitId; item.DebitId = Debits.Insert(item); foreach (var debit in booking.Debits) { if (debit.RefDebitId == fakeId) { debit.RefDebitId = item.DebitId; } } } foreach (ScannedDocument item in booking.ScannedDocuments) { item.RefBookingId = bookingId; } ScannedDocuments.Insert(booking.ScannedDocuments); foreach (BookingCostCenterMapping item in booking.BookingCostCenterMappingList) { item.RefBookingId = bookingId; } BookingCostCenterMappings.Insert(booking.BookingCostCenterMappingList); } BookingList.Clear(); SelectedBooking = null; }
public Ekonomi() { InitializeComponent(); //Hämtar bookinglisten via serviceprovidern. Serviceprovidern hämtar via den sparade bookingfilen. Kan skapa errors, därför en trysats. try { bookingList = ServiceProvider.GetBookingService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //Hämtar customerlisten via serviceprovidern. Serviceprovidern hämtar via den sparade customerfilen. Kan skapa errors, därför en trysats. try { customerList = ServiceProvider.GetCustomerService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //Hämtar cabinlisten via serviceprovidern. Serviceprovidern hämtar via den sparade cabinfilen. Kan skapa errors, därför en trysats. try { cabinList = ServiceProvider.GetCabinService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //tbxHusvagnPris.Text = priceList.Get(1).ToString(); //tbxStugpris.Text = priceList.Get(2).ToString(); //tbxKWHpris.Text = priceList.Get(3).ToString(); try { priceList = ServiceProvider.GetPriceService(); } catch (Exception ex) { MessageBox.Show(ex.Message); } initListView(); }
private void CreateJoinedList() { var list = new BookingList("Gesamtliste"); list.Occurrence = _occ; foreach (var occurrenceGroup in _occ.Groups.Where(x => x.SemesterGroups.Any())) { var curr = occurrenceGroup.SemesterGroups.First().CapacityGroup.CurriculumGroup.Curriculum; if (!list.Curricula.Contains(curr)) { list.Curricula.Add(curr); } } _lists.Add(list); }
private void DisplayData() { String UserName = Convert.ToString(Session["User"]); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Comp229TeamProjectConnectionString"].ToString()); SqlCommand comm = new SqlCommand("select a.DateStart, a.DateEnd, b.CarModel from dbo.CarLine a join dbo.Cars b on b.CarID = a.CarID where a.CustomerID = (select CustomerID from dbo.Customer where Username = @UserName)", conn); conn.Open(); comm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar); comm.Parameters["@UserName"].Value = UserName; SqlDataReader reader = comm.ExecuteReader(); BookingList.DataSource = reader; BookingList.DataBind(); reader.Close(); conn.Close(); }
public static BookingList GetBookingService() { if (_bookingService == null) { try { _bookingService = new BookingList(); } catch (Exception) { throw; } } return(_bookingService); }
private void CreateListByCurriculum() { foreach (var occurrenceGroup in _occ.Groups.Where(x => x.SemesterGroups.Any())) { var curr = occurrenceGroup.SemesterGroups.First().CapacityGroup.CurriculumGroup.Curriculum; var list = _lists.FirstOrDefault(x => x.Curricula.Any(c => c.Id == curr.Id)); if (list == null) { list = new BookingList(""); list.Group = occurrenceGroup; list.Occurrence = _occ; list.Curricula.Add(curr); _lists.Add(list); } } }
public BookingList GetMyBookings() { var obj = new BookingList(); try { var result = SendGet(GET_MY_BOOKINGS, new List <Tuple <string, string> >()); obj.Bookings = JsonConvert.DeserializeObject <List <Booking> >(result); obj.Status = HttpStatusCode.OK; } catch (WebException ex) { FormErrorResponse(ex, obj); } return(obj); }
public SearchDataResponse SearchDataByCustomerId(int customerId) { var result = new SearchDataResponse { ListBookings = BookingList.Where(b => b.CustomerId == customerId).OrderByDescending(x => x.BookingId).ToList(), ListCustomerInfos = new List <CustomerInfos>() }; result.ListBookings.ForEach(booking => { var product = ProductList.FirstOrDefault(p => p.ProductId == booking.ProductId); booking.BookingsTypeString = product != null ? GetProductType(product.ProductType) : string.Empty; }); return(result); }
//Används endast i AddBooking, utför bokningen public void AddBookingMethod(Apartment apartment, string bookingDate, LaundryTime laundryTime) { BookingList newBooking = new BookingList(); newBooking.Apartment = apartment; newBooking.bookedDate = bookingDate; newBooking.LaundryTime = laundryTime; try { con.BookingList.Add(newBooking); con.SaveChanges(); } catch (InvalidOperationException) { con.BookingList.Remove(newBooking); throw new DatabaseException("Databasfel, kontakta systemadminstratör!"); } }
/// <summary> /// Creates a new booking item, selects it and adds it to the BookingList /// </summary> /// <param name="date"></param> /// <param name="description"></param> public void NewBookingItem(DateTime date, string description) { if (string.IsNullOrEmpty(description)) { throw new Exception("Bitte Kontenrahmen angeben."); } Booking booking = new Booking(date, description); booking.BookingId = tempBookingId; tempBookingId++; SelectedBooking = booking; if (BookingList == null) { BookingList = new ObservableCollection <Booking>(); } BookingList.Add(booking); }
public ActionResult Index() { using (PonyContext db = new PonyContext()) { var userid = User.Identity.GetUserId(); List <Booking> bookings = db.Bookings.Where(x => x.CustomerID == userid).OrderBy(x => x.Day).ToList(); List <BookingList> bookingsList = new List <BookingList>(); BookingList bookingList; foreach (Booking booking in bookings) { bookingList = new BookingList(); bookingList.Day = booking.Day.ToShortDateString(); bookingList.Session = getSession(booking.Session); bookingList.PonyName = db.Ponies.Find(booking.PonyID).Name; bookingList.PonyPicture = db.Ponies.Find(booking.PonyID).Picture; bookingList.SessionID = booking.ID; bookingsList.Add(bookingList); } return(View(bookingsList)); } }
public void deleteBookingTest() { CarList carList = new CarList(); Booking booking = new Booking(); Guid id = new Guid(); Guid vehicleId = new Guid(); // this is just a sample data booking.id = id; booking.Vehicleid = vehicleId; booking.CustomerName = "Kopal"; booking.StartOdometer = 100; booking.SelectedVehicle = "BMW Z4"; booking.StartRentDate = DateTime.Now; booking.EndRentDate = DateTime.Now; booking.RentalType = (BookingType)Enum.Parse(typeof(BookingType), "Day"); CarList.bookings.Add(booking); // check if its deleted or not by this method Assert.IsTrue(BookingList.deleteBooking(booking)); }
public async Task SearchBookingCar() { if (EndDate == StartDate) { await Application.Current.MainPage.DisplayAlert("Warning", "The search interval should be at least 1 day", "Try again"); return; } if (EndDate <= StartDate) { await Application.Current.MainPage.DisplayAlert("Warning", "End date must be greater than start date", "Try again"); return; } var request = new BookingSearchRequest { ManufacturerName = ManufacturerName, StartDate = StartDate, EndDate = EndDate }; var list = await _serviceBooking.Get <IEnumerable <Data.Model.Booking> >(request); BookingList.Clear(); foreach (var item in list) { item.EndDate = item.EndDate.AddHours(8).Date; BookingList.Add(item); } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "There are no results for this search", "Try again"); } }
//Retunerar en användares aktiva bokning public List <BookingList> GetSingleBooking(string apartmentNr) { try { List <BookingList> bookingList = con.BookingList.Where(r => r.apartmentNr == apartmentNr).ToList(); List <BookingList> newBookingList = new List <BookingList>(); if (bookingList.Count == 0) { return(null); } else { foreach (BookingList b in bookingList) { BookingList tempBook = new BookingList(); DateTime oldBooking = DateTime.ParseExact(b.bookedDate + " " + b.bookedLaundryTime + "", "dd-MM-yyyy HH:mm", null); if (oldBooking > DateTime.Now) { tempBook.Apartment = b.Apartment; tempBook.apartmentNr = b.apartmentNr; tempBook.bookedDate = b.bookedDate; tempBook.bookedLaundryTime = b.LaundryTime.description; tempBook.LaundryTime = b.LaundryTime; newBookingList.Add(tempBook); } } return(newBookingList); } } catch (InvalidOperationException) { throw new DatabaseException("Databasfel, kontakta systemadminstratör"); } }
public ActionResult Save(PassengerModel model, string selectedSeats, long boardingPoint, long droppingPoint, string payment) { if (ModelState.IsValid) { try { binder.passenger.Add(model); binder.SaveChanges(); BookingModel bkModel = new BookingModel(); bkModel.PassengerId = model.Id; bkModel.TripId = trpId; bkModel.BoardingPoint = boardingPoint; bkModel.DroppingPoint = droppingPoint; bkModel.PaymentMethod = payment; binder.booking.Add(bkModel); binder.SaveChanges(); string[] seat = selectedSeats.Split(' '); for (int i = 0; i < seat.Length - 1; i++) { BookingList bkList = new BookingList(); bkList.BookingId = bkModel.Id; bkList.SeatNo = seat[i]; binder.bookingList.Add(bkList); binder.SaveChanges(); } } catch (Exception e) { } } return(RedirectToAction("Index", "Home")); }
public BookingList QuickSearchBooking(int userId, Hashtable filters, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; BookingList booking = new BookingList(); booking.Data = new List <BookingForwarder>(); booking.TotalRows = 0; var pageSize = 20; var pageIndex = 1; var sortedBy = string.Empty; var sortedDirection = string.Empty; if (filters.ContainsKey("pageSize")) { pageSize = Convert.ToInt32(filters["pageSize"].ToString()); } if (filters.ContainsKey("pageIndex")) { pageIndex = Convert.ToInt32(filters["pageIndex"].ToString()); } if (filters.ContainsKey("sortedBy")) { sortedBy = filters["sortedBy"].ToString(); } if (filters.ContainsKey("sortedDirection")) { sortedDirection = filters["sortedDirection"].ToString(); } try { using (var context = CreateContext()) { string bookingUD = null; string blNo = null; string forwarderID = null; if (filters.ContainsKey("searchQuery") && filters["searchQuery"] != null) { bookingUD = filters["searchQuery"].ToString().Replace("'", "''"); } if (filters.ContainsKey("forwarderID") && filters["forwarderID"] != null) { forwarderID = filters["forwarderID"].ToString().Replace("'", "''"); } booking.TotalRows = context.Support_function_QuickSearchBookingForwarder(bookingUD, /*blNo,*/ forwarderID, /*userId,*/ sortedBy, sortedDirection).Count(); var result = context.Support_function_QuickSearchBookingForwarder(bookingUD, /*blNo,*/ forwarderID, /*userId,*/ sortedBy, sortedDirection); booking.Data = _converter.DB2DTO_BookingForwader(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; } return(booking); }
public ListResult <Surveys> SearchSurveys(int hotelId, DateTime?startDate, DateTime?endDate, int pageNumber = 1) { var result = new ListResult <Surveys>(); var surveys = (from p in SurveyList join p1 in BookingList on p.BookingId equals p1.BookingId join p2 in ProductList on p1.ProductId equals p2.ProductId join p3 in HotelList on p2.HotelId equals p3.HotelId where p3.HotelId == hotelId && p.IsFinish && !p.IsDelete orderby p1.RedeemedDate descending select p).ToList(); // Assign CheckInDate if (surveys.Any()) { surveys.ForEach(item => { var bookings = BookingList.FirstOrDefault(b => b.BookingId == item.BookingId); if (bookings != null) { item.CheckInDate = bookings.CheckinDate; } }); } if (startDate.HasValue) { surveys = surveys.Where(x => x.CheckInDate.HasValue && x.CheckInDate.Value.Date >= startDate.Value.Date).ToList(); } if (endDate.HasValue) { surveys = surveys.Where(x => x.CheckInDate.HasValue && x.CheckInDate.Value.Date <= endDate.Value.Date).ToList(); } result.TotalRecords = surveys.Count(); surveys = pageNumber <= 1 ? surveys.Take(Constant.ItemPerPage).ToList() : surveys.Skip((pageNumber - 1) * Constant.ItemPerPage).Take(Constant.ItemPerPage).ToList(); if (surveys.Any()) { surveys.ForEach(item => { double spend = 0; if (item.IsBuyFoodAndDrink && item.FoodAndDrinkPrice.HasValue) { spend += item.FoodAndDrinkPrice.Value; } if (item.IsPayForParking) { spend += Constant.ParkingPrice; } if (item.IsBuySpaService && item.SpaServicePrice.HasValue) { spend += item.SpaServicePrice.Value; } if (item.IsBuyAdditionalService && item.AdditionalServicePrice.HasValue) { spend += item.AdditionalServicePrice.Value; } item.EstSpend = spend; item.RedeemedDate = item.Bookings.RedeemedDate; }); } result.Items = surveys.ToList(); return(result); }