示例#1
0
 // DESCRIPTION: Creates reservation or adds to waitlist depending on availability
 private void btnMakeRes_Click(object sender, EventArgs e)
 {
     if (waitlist == true)
     {
         // add request to waitlist
         Waitlist addToWaitlist = new Waitlist();
         addToWaitlist.addToWaitlist(resUserID, Convert.ToInt32(cboxHotel.SelectedValue), startDate.Value, endDate.Value, Convert.ToInt32(cboxNumGuests.SelectedItem), Convert.ToInt32(cboxNumRooms.SelectedItem), combinedstring);
         lblError.ForeColor = System.Drawing.Color.Green;
         lblError.Text      = "You have been added to the waitlist";
     }
     //If creating reservation
     else
     {   // Get next confirmation ID
         Reservation createReservation = new Reservation();
         int         confirmationID    = createReservation.makeReservation(Convert.ToInt32(cboxHotel.SelectedValue), userID, resUserID, startDate.Value, endDate.Value, price, points, roomNumList, Convert.ToInt32(cboxNumGuests.SelectedItem), currentDate);
         if (startDate.Value == currentDate)
         {
             Reservation resCheckin = new Reservation(confirmationID);
             resCheckin.checkInReservation(currentDate);
         }
         var makePayment = new Payment(confirmationID, resUserID, currentDate, true);
         makePayment.FormClosed += new FormClosedEventHandler(makePayment_FormClosed);
         this.Hide();
         makePayment.Show();
     }
 }
示例#2
0
        public async Task <IActionResult> PutWaitlist(int id, Waitlist waitlist)
        {
            if (id != waitlist.WaitlistId)
            {
                return(BadRequest());
            }

            _context.Entry(waitlist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WaitlistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> AddToWaitlist(string ISBN)
        {
            //check if waitlist exists; if not: create a new one for the associated book

            var bookWaitlist = GetWaitlist(ISBN);

            if (bookWaitlist == null)
            {
                var new_waitlist = new Waitlist(ISBN);
                _context.Waitlists.Add(new_waitlist);
                _context.SaveChanges();
            }
            bookWaitlist = GetWaitlist(ISBN);

            var userEmail   = HttpContext.Items["Email"] as string;
            var userId      = _context.Users.FirstAsync(x => x.Email == userEmail).Id;
            var checkExists =
                _context.WaitingPeople.FirstOrDefault(
                    x => x.UserUserID == userId && x.WaitlistListID == bookWaitlist.ListID);

            if (checkExists == null)
            {
                var waitingList = new Waiting(userId, bookWaitlist.ListID ?? default(int));
                _context.WaitingPeople.Add(waitingList);
                _context.SaveChanges();
            }


            return(Ok());
        }
示例#4
0
        public async Task <ActionResult <Waitlist> > PostWaitlist(Waitlist waitlist)
        {
            _context.Waitlists.Add(waitlist);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWaitlist", new { id = waitlist.WaitlistId }, waitlist));
        }
示例#5
0
        public async Task <IActionResult> AddBook(AddBookRequest request)
        {
            //ADD LONG BLOB FOR IMAGESSSSSSS
            // DON'T FORGET THAT we need to add long blobs
            var book_new = new Book(request.Isbn, request.Name, request.Author, request.Genre, request.ReleaseDate, request.Publisher);

            _context.Books.Add(book_new);
            _context.SaveChanges();

            var new_waitlist = new Waitlist(request.Isbn);

            _context.Waitlists.Add(new_waitlist);
            _context.SaveChanges();

            return(Ok());
        }
示例#6
0
        public IActionResult JoinWaitlist([FromBody] WaitlistForCreationDto w)
        {
            var library = _dbContext.Libraries.FirstOrDefault(l => l.Id == w.LibraryId);
            var user    = _dbContext.Users.FirstOrDefault(u => u.Id == w.UserId); //change later to get from token (?)

            if (library == null || user == null)
            {
                return(NotFound());
            }

            var waitlist = new Waitlist {
                Library = library, User = user, RequestedOn = DateTime.Now, IsActive = true
            };

            _dbContext.Add(waitlist);
            _dbContext.SaveChanges();

            return(Ok());
        }
示例#7
0
        // DESCRIPTION: Checks for reservation availability
        private void btnSubmit_Click(object sender, EventArgs e)
        {  // reset error
            lblError.Visible = false;

            Utilities calcPrice = new Utilities();

            if (checkPackages.GetItemCheckState(0) == CheckState.Unchecked)
            {
                checkPackages.SetItemCheckState(0, CheckState.Checked);
                displayError("All rooms contain basic package.");
            }

            // verify fields are valid
            if (startDate == null)
            {
                displayError("Please select a start date");
            }
            else if (endDate == null)
            {
                displayError("Please select an end date");
            }
            else if (startDate < currentDate)
            {
                displayError("Selected start date cannot be in the past");
            }
            else if (endDate < startDate)
            {
                displayError("Selected end date is earlier than selected start date");
            }
            else if (cboxNumGuests.SelectedItem == null)
            {
                displayError("Please select number of guests");
            }
            else if (cboxHotel.SelectedItem == null)
            {
                displayError("Please select a hotel");
            }
            else if (cboxNumRooms.SelectedItem == null)
            {
                displayError("Please select number of rooms");
            }
            else
            {
                combinedstring = getSelectedPackages();

                // check for availability
                Reservation resInfo    = new Reservation();
                int         locationID = Convert.ToInt32(cboxHotel.SelectedValue);
                int         numGuests  = Convert.ToInt32(cboxNumGuests.SelectedItem);
                int         numRooms   = Convert.ToInt32(cboxNumRooms.SelectedItem);


                roomNumList = resInfo.getAvailability(numGuests, locationID, numRooms, combinedstring, currentDate, startDate.Value, endDate.Value);

                if (roomNumList.Count != numRooms)
                {   // no room available, gets roomNum to reference for price
                    if (mod)
                    {
                        displayError("Modifications unavailable");
                    }
                    else
                    {
                        // get room to reference for waitlist price
                        Waitlist getRefRoom = new Waitlist();
                        int      refRoomNum = getRefRoom.getRefRoomforWIL(locationID, combinedstring);
                        if (refRoomNum != -1)
                        {
                            Room getWLPricePerNight = new Room(refRoomNum, Convert.ToInt32(cboxHotel.SelectedValue));
                            pricePerNight = getWLPricePerNight.price;
                            displayError("No room with those criteria are available. Your reservation will be added to the waitlist");
                            waitlist = true;
                        }
                        else
                        {
                            displayError("No room with those criteria exists");
                            return;
                        }
                    }
                }
                else
                {
                    Room roomDetails = new Room(roomNumList[0], locationID);

                    // calculate price and rewards
                    if (mod)
                    {   // if free upgrade, do not change price per night
                        if (checkFreeUpgrade.CheckState == CheckState.Checked)
                        {
                            pricePerNight = (modResInfo.totalPrice / modResInfo.duration);
                        }
                        else
                        {
                            pricePerNight    = roomDetails.price * numRooms;
                            lblError.Visible = false;
                        }
                    }
                    else
                    {
                        pricePerNight    = roomDetails.price * numRooms;
                        lblError.Visible = false;
                    }
                }
                price  = calcPrice.calculatePrice(((endDate.Value - startDate.Value).TotalDays), pricePerNight);
                points = Convert.ToInt32(calcPrice.calculatePoints(((endDate.Value - startDate.Value).TotalDays)));

                // fill fields
                txtCostNightly.Text   = pricePerNight.ToString();
                lblSubTotal.Text      = price.ToString();
                cboxHotel.Enabled     = false;
                cboxNumRooms.Enabled  = false;
                cboxNumGuests.Enabled = false;
                monthStart.Enabled    = false;
                monthEnd.Enabled      = false;
                checkPackages.Enabled = false;
                btnSubmit.Visible     = false;

                if (mod)
                {
                    btnModify.Visible = true;
                }
                else
                {
                    btnMakeRes.Visible = true;
                }
            }
        }
示例#8
0
 public void Dispose() => waitlist = null;
示例#9
0
 public void Init() => waitlist = new Waitlist();
示例#10
0
        public async Task <ActionResult> DownWaitlistIneligableAsync()
        {
            List <Student> students = _context.Students.ToList();
            List <Course>  courses  = _context.Courses.ToList();
            // Assume all waitlist distinct!
            List <Waitlist> waitlists = _context.Waitlists.ToList();
            List <List <StudentEligibility> > allEligabilities = new List <List <StudentEligibility> >();

            foreach (Course course in courses)
            {
                allEligabilities.Add(await _coursesController.GetInEligableCourseByCourseIdAsync(course.CourseId));
            }

            Dictionary <Waitlist, StudentEligibility> failedWaitlistDict = new Dictionary <Waitlist, StudentEligibility>();

            foreach (Waitlist waitlist in waitlists)
            {
                bool hasMatch = false;

                foreach (List <StudentEligibility> studentEligibilities in allEligabilities)
                {
                    foreach (StudentEligibility eligibility in studentEligibilities)
                    {
                        if (waitlist.StudentId == eligibility.StudentId && waitlist.CourseId == eligibility.CourseId)
                        {
                            failedWaitlistDict.Add(waitlist, eligibility);
                            hasMatch = true;
                            break;
                        }
                    }

                    if (hasMatch)
                    {
                        break;
                    }
                }
            }

            List <KeyValuePair <Waitlist, StudentEligibility> > failedList = failedWaitlistDict.ToList();

            failedList.Sort((a, b) => a.Key.WaitlistId.CompareTo(b.Key.WaitlistId));

            List <string> headers = new List <string>()
            {
                "Id",
                "Student Id",
                "Student Name",
                "Course Id",
                "CRN",
                "Term",
                "Failed Prerequisites"
            };

            List <List <string> > data = new List <List <string> >();



            if (failedList.Count > 0)
            {
                KeyValuePair <Waitlist, StudentEligibility> last = failedList.Last();

                foreach (KeyValuePair <Waitlist, StudentEligibility> f in failedList)
                {
                    Waitlist           waitlist    = f.Key;
                    StudentEligibility eligibility = f.Value;

                    string studentName = null;

                    try
                    {
                        studentName = students.Where(s => s.StudentId == waitlist.StudentId).First().StudentName;
                    }
                    catch (Exception)
                    {
                        studentName = "";
                    }

                    List <string> row = new List <string>()
                    {
                        waitlist.WaitlistId.ToString(),
                                  waitlist.StudentId,
                                  studentName,
                                  waitlist.CourseId,
                                  waitlist.CRN,
                                  waitlist.Term,
                                  eligibility.FailedPrereqs.Count > 0 ? eligibility.FailedPrereqs[0] : null
                    };

                    data.Add(row);

                    if (eligibility.FailedPrereqs.Count > 1)
                    {
                        foreach (string courseId in eligibility.FailedPrereqs.Skip(1))
                        {
                            List <string> courseIdRow = new List <string>()
                            {
                                null, null, null, null, null, null, courseId
                            };

                            data.Add(courseIdRow);
                        }
                    }

                    data.Add(new List <string>(6));

                    if (!f.Equals(last))
                    {
                        data.Add(headers);
                    }
                }
            }

            // data = data.OrderBy(a => a[0]).ToList();

            Stream excel = ExcelWriter.CreateAsStream(headers, data);

            return(new FileStreamResult(excel, "application/octet-stream")
            {
                FileDownloadName = "waitlist-ineligible.xlsx"
            });
        }