protected void btnSearch_Click(object sender, EventArgs e) { //load StudentConnection connection = new StudentConnection(); //Get all students from selected varsity string query = " Institution = " + "'" + txtText.Text + "'"; List <Qaelo.Models.StudentModel.Student> students = connection.getAllStudents(query); // Get the books made by these students List <Book> books = new List <Book>(); foreach (Qaelo.Models.StudentModel.Student student in students) { //check if they have books and add to list List <Book> studentBooks = connection.getAllStudentBoks(student.Id); foreach (Book book in studentBooks) { // check whether the books match the search filter if (book.Field == ddlField.SelectedItem.Value && book.YearOfStudy == ddlYear.SelectedItem.Value) { books.Add(book); } } } //List<Book> books = connection.getAllBooks(); lblBooks.Text = ""; int count = 0; foreach (Book book in books) { if (connection.isProfilePublic(book.StudentId)) { count++; string desc = ""; if (book.Description.Length > 65) { desc = book.Description.Substring(0, 65); } else { desc = book.Description; } lblBooks.Text += string.Format(@"<div class='col-sm-6' style='margin-bottom:20px'> <div class='col-sm-6'> <img src = '../../../Images/Book/{0}' class='img-thumbnail' style='height:150px;width:100%' id='image1'/> <br/><br/> </div> <div class='col-sm-6'> <p style='font-size:smaller;font-style:normal'><strong>Title: <strong style='color:red'>{1}</strong></strong></p> <p style='font-size:smaller;font-style:normal'><strong>Study Field: <strong style='color:dimgrey'>{2}</strong></strong></p> <p style='font-size:smaller;font-style:normal'><strong>Year of Study: <strong style='color:dimgrey'>{3}</strong></strong></p> <p style='font-size:smaller;font-style:normal'><strong>Price: R<strong style='color:dimgrey'>{4}.00</strong></strong></p> <a href='#book{5}' class='btn btn-default btn-md' data-toggle='modal' style='background:#d89b4e'>More info</a> </div> </div>", book.Image, book.Name, book.Field, book.YearOfStudy, book.Price, book.Id); //Modal //get student Qaelo.Models.StudentModel.Student student = connection.getStudent(book.StudentId); lblBooks.Text += string.Format(@"<div class='modal fade' id='book{7}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel{1}' aria-hidden='true'> <div class='modal-dialog modal-lg'> <div class='modal-content'> <div class='modal-body'> <div class='container'> <div class='col-sm-10'> <div class='col-sm-4'> <h2>Book Image</h2> <img src = '../../../Images/Book/{0}' class='img-thumbnail' style='height:350px;width:100%' id='image1'/><br/><br/> </div> <div class='col-sm-4'> <h2>About the book</h2> <label><strong>Title:</strong></label>{1}<br /> <label><strong>Description:</strong></label>{2}<br/><br /> <label><strong>Price:</strong> {3}</label><br/><br /> </div> <div class='col-sm-3'> <h2>Seller info</h2> <label><strong>Seller Name:</strong></label>{4}<br/> <label><strong>Seller Number:</strong></label>{5}<br/> <label><strong>University:</strong></label>{6}<br/> </div> </div> </div> </div> <div class='modal-footer'> <button class='btn btn-default pull-left' data-dismiss='modal'>Cancel</button> </div> </div> </div> </div>", book.Image, book.Name, book.Description, book.Price, student.FirstName, student.Number, student.Institution, book.Id); } } }
protected void btnSearch_Click(object sender, EventArgs e) { //load StudentConnection connection = new StudentConnection(); //Get all students from selected varsity string query = " Institution = " + "'" + txtText.Text + "'"; List <Qaelo.Models.StudentModel.Student> students = connection.getAllStudents(query); List <Qaelo.Models.StudentModel.Freelancer> freelancers = new List <Models.StudentModel.Freelancer>(); //add each profile to freelance list foreach (Qaelo.Models.StudentModel.Freelancer freelancer in connection.getAllFreelancers()) { //add student as freelance if (connection.getStudent(freelancer.StudentId) != null) { if (connection.getStudent(freelancer.StudentId).Institution.Equals(txtText.Text)) { if (freelancer.Work.Contains(txtFreelancers.Text)) { freelancers.Add(freelancer); } } } } string html = ""; int length = General.getLengthOfLongestFreelancer(freelancers); foreach (Models.StudentModel.Freelancer freelancer in freelancers) { if (connection.isProfilePublic(freelancer.StudentId)) { //if a student is a freelancer then include it here string[] abilities = freelancer.Work.Split(';'); string work = ""; for (int i = 0; i < abilities.Count(); i++) { if (abilities[i].Count() > 0) { if ((i + 1) == abilities.Count()) { work += abilities[i]; } else { if (abilities[i].Count() > 4) { work += "<li>" + abilities[i] + "</li>"; } //work += "." + abilities[i] + "." + "<br/>"; } } } string fr = "<h6 style='margin-top:10px'>I freelance as a : <br/><ul></h6><small style='font-size:12px'>" + work + "</b></small><ul/>"; Qaelo.Models.StudentModel.Student student = connection.getStudent(freelancer.StudentId); string[] images = freelancer.Image.Split(';'); html += string.Format(@" <div class='col-md-3 thumbnail'> <div class='w3-card-12'> <figure > <img src='../../../Images/Users/Students/{0}' style='height:220px;width:100%' /> <figcaption style = 'background-image: url('')'> {1} </figcaption> </figure> <div class='w3-container' style='margin:10px'> <h6><b>{2} - <small style='font-size:12px'>{3}</small></b></h6> {4}<br/> <a href='#freelancer{5}' data-toggle='modal' class='btn pull-right form-control' style='background:#d89b4e'>View profile</a> <br/><br/> </div> </div> </div> ", student.ProfileImage, student.Description, student.FirstName + student.LastName, student.Institution, fr, student.Id); //Modal pop up //Get freelance portfolio PreviousWork portfolio = connection.getPortfolio(student.Id); string image1 = "default.jpg"; string image2 = "default.jpg"; string image3 = "default.jpg"; string video1 = "videoDefault.mp4"; string video2 = "videoDefault.mp4"; string video3 = "videoDefault.mp4"; string cvDescription = ""; if (portfolio != null) { //Test for images string[] pictures = portfolio.Pictures.Split(';'); if (pictures[0] != string.Empty) { image1 = pictures[0]; } if (pictures[1] != string.Empty) { image2 = pictures[1]; } if (pictures[2] != string.Empty) { image3 = pictures[2]; } //Test for videos string[] videos = portfolio.Videos.Split(';'); if (videos[0] != string.Empty) { video1 = videos[0]; } if (videos[1] != string.Empty) { video2 = videos[1]; } if (videos[2] != string.Empty) { video3 = videos[2]; } cvDescription = portfolio.Links; } lblSingleProfile.Text += string.Format(@"<div class='modal fade' id='freelancer{11}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'> <div class='modal-dialog modal-lg'> <div class='modal-content'> <div class='modal-body'> <div class='container'> <div class='col-sm-9'> <div class='col-sm-5'> <h2>Education</h2> <hr /> <strong>University:</strong><p>{0}</p> <strong>Course Enrolled:</strong><p>{1}</p> <strong>Freelance:</strong><p>{2}</p> <strong>Freelancing Description:</strong><p>{3}</p> <strong>Price:</strong><p>{4}</p> </div> <div class='col-sm-5'> <h2>Contact Info</h2> <hr /> <strong>Full Name :</strong><p>{5}</p> <strong>Email:</strong><p>{6}</p> <strong>Phone No:</strong><p>{7}</p> </div> </div> <div class='col-sm-9' style='margin-top:50px'> </div> <!-- Portfolio--> <div class='col-sm-9'> <div class='panel-group' id='accordion{11}'> <div class='panel panel-warning'> <div class='panel-heading'> <h4 class='panel-title'> <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse1{11}'> View My Portfolio Pictures</a> </h4> </div> <div id='collapse1{11}' class='panel-collapse collapse in'> <div class='panel-body'> <div class='col-sm-12'> <div class='col-sm-4'> <a id='popover1{11}' class='btn' rel='popover1{11}' data-content='' > <img src='../../../Images/Freelancer/{12}' class='img-thumbnail' /> </a> </div> <div class='col-sm-4'> <a id='popover2{11}' class='btn' rel='popover2{11}' data-content='' > <img src='../../../Images/Freelancer/{13}' class='img-thumbnail' /> </a> </div> <div class='col-sm-4'> <a id='popover3{11}' class='btn' rel='popover3{11}' data-content='' > <img src='../../../Images/Freelancer/{14}' class='img-thumbnail' /> </a> </div> </div> </div> </div> </div> </div> <!-- Next conetent here--> <div class='panel panel-warning'> <div class='panel-heading'> <h4 class='panel-title'> <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse2{11}'> View My Portfolio Videos</a> </h4> </div> <div id='collapse2{11}' class='panel-collapse collapse'> <div class='panel-body'> <div class='col-sm-12'> <div class='col-sm-4'> <video src='../../../Images/Freelancer/{15}' class='img-thumbnail' style='height:150px;' controls='controls' /> </div> <div class='col-sm-4'> <video src='../../../Images/Freelancer/{16}' class='img-thumbnail' style='height:150px;' controls='controls' /> </div> <div class='col-sm-4'> <video src='../../../Images/Freelancer/{17}' class='img-thumbnail' style='height:150px;' controls='controls' /> </div> </div> </div> </div> </div> <!-- Next content here--> <div class='panel panel-warning'> <div class='panel-heading'> <h4 class='panel-title'> <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse3{11}'> View My Portfolio CV</a> </h4> </div> <div id='collapse3{11}' class='panel-collapse collapse'> <div class='panel-body'> <div class='col-sm-12'> <p> {18} </p> </div> </div> </div> </div> </div> </div> <div class='modal-footer'> <button class='btn btn-default pull-left' data-dismiss='modal'>Cancel</button> </div> </div> </div> </div> </div>", student.Institution, student.QualificationEnrolled, freelancer.Work, freelancer.Description, freelancer.Price, student.FirstName + " " + student.LastName, student.Email, student.Number, images[0], images[1], images[2], student.Id, image1, image2, image3, video1, video2, video3, cvDescription); } } if (html.Length > 0) { lblProfileView.Text = html; } }