예제 #1
0
        // GET: Courses
        public async Task <IActionResult> Index(int?courseSemester, string courseProgram, string searchString)
        {
            IQueryable <Course> courses = _context.Course.AsQueryable();

            courses = _context.Course.Include(c => c.FirstTeacher).Include(c => c.SecondTeacher).Include(c => c.Students).ThenInclude(c => c.Student);
            IQueryable <int>    semesterQuery = _context.Course.OrderBy(m => m.Semester).Select(m => m.Semester).Distinct();
            IQueryable <string> programQuery  = _context.Course.OrderBy(m => m.Program).Select(m => m.Program).Distinct();

            if (!string.IsNullOrEmpty(searchString))
            {
                courses = courses.Where(s => s.Title.Contains(searchString));
            }
            if (courseSemester != null)
            {
                courses = courses.Where(x => x.Semester == courseSemester);
            }
            if (!string.IsNullOrEmpty(courseProgram))
            {
                courses = courses.Where(x => x.Program == courseProgram);
            }

            var searchCourseVM = new SearchCourse
            {
                Semesters = new SelectList(await semesterQuery.ToListAsync()),
                Programs  = new SelectList(await programQuery.ToListAsync()),
                Courses   = await courses.ToListAsync()
            };

            return(View(searchCourseVM));
        }
        public ActionResult SearchCoursesPartial(string userId, string keyWord, int currentPage)
        {
            AppUser currentUser = userManager.Users.FirstOrDefault(u => u.Id == userId);

            List <SearchCourse> courses = new List <SearchCourse>();

            foreach (Course course in repository.Courses.Where(c =>
                                                               c.CreatedBy.CompanyName == currentUser.CompanyName ||
                                                               c.CreatedBy.CompanyName == null))
            {
                if (course.CreatedBy != null && course.Status == "Private")
                {
                    if (course.CreatedBy.Id == currentUser.Id)
                    {
                        if (SearchWordExists(course.Title, keyWord))
                        {
                            SearchCourse searchCourse = new SearchCourse
                            {
                                Course    = course,
                                CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                            };
                            courses.Add(searchCourse);
                        }
                    }
                }
                else if (course.Status == "Public")
                {
                    if (SearchWordExists(course.Title, keyWord))
                    {
                        SearchCourse searchCourse = new SearchCourse
                        {
                            Course    = course,
                            CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                        };
                        courses.Add(searchCourse);
                    }
                }
            }

            SearchAllCourses allCourses = new SearchAllCourses
            {
                AllCourses = courses.AsQueryable()
                             .OrderBy(c => c.Course.Title)
                             .Skip((currentPage - 1) * MaxSearchPageCourse)
                             .Take(MaxSearchPageCourse),
                CoursePageInfo = new SearchCoursePageInfo
                {
                    CurrentPage    = currentPage,
                    TotalCourses   = courses.AsQueryable().Count(),
                    CoursesPerPage = MaxSearchPageCourse
                }
            };

            return(PartialView("SearchCoursesPartial", allCourses));
        }
예제 #3
0
    /// <summary>
    /// Populate new search result depending on new selection criteria
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        SearchCourse objSearchCourse = buildSearchCriteria();

        objSearchCourse.SortColumn = "StartDate";
        objSearchCourse.SortOrder  = "DESC";

        //Add search criteria into session
        Session.Add(LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA, objSearchCourse);
        Response.Redirect("CourseResult.aspx");
    }
예제 #4
0
    protected void Search(object sender, EventArgs e)
    {
        IList <Course> courseResult    = new List <Course>();
        SearchCourse   objSearchCourse = buildSearchCriteria();
        int            itemIndex       = 0;

        int              totalCount    = 0;
        string           strStartDate  = txtStartDate.Text;
        string           strEndDate    = txtEndDate.Text;
        string           strSearchTerm = txtKeyword.Text;
        CourseDataAccess objCourseDAL  = new CourseDataAccess();

        try
        {
            courseResult = objCourseDAL.GetPagedCourseBySearch(strStartDate, strEndDate, strSearchTerm, 1,
                                                               250, "", ref totalCount);

            string resultsNumber = courseResult.Count.ToString();
            existingCourcesDiv.InnerHtml  = "<div class='title'>Upload or Edit Attendees</div>";
            existingCourcesDiv.InnerHtml += "<div class='existingCources'>";
            existingCourcesDiv.InnerHtml += "<table cellpadding='0' width='100%'><tr><td class='TableHeader' width='37%'>Course Title</td><td class='TableHeader' width='11%'>Start Date</td><td class='TableHeader' width='10%'>End Date</td><td class='TableHeader' width='27%'>Upload Attendees in Excel</td><td class='TableHeader' width='15%'>Edit Attendees</td></tr>";
            existingCourcesDiv.InnerHtml += "<tbody id='course_list'>";
            foreach (Course c in courseResult)
            {
                existingCourcesDiv.InnerHtml += "<tr><td class='grayText'><a href=CourseDetails.aspx?courseid=" + c.ID + ">" + Server.HtmlEncode(c.Title) + "</a></td>";
                existingCourcesDiv.InnerHtml += "<td class='grayText'>" + c.StartDate.ToShortDateString() + "</td>";
                existingCourcesDiv.InnerHtml += "<td class='grayText'>" + c.EndDate.ToShortDateString() + "</td>";
                existingCourcesDiv.InnerHtml += "<td align='center'><a href=UploadAttendees.aspx?courseid=" + c.ID + ">Upload</a></td>";
                existingCourcesDiv.InnerHtml += "<td align='center'><a href=EditAllCourseAttendees.aspx?CourseID=" + c.ID + ">Edit</a></td></tr>";
            }
            existingCourcesDiv.InnerHtml += "</tbody>";
            existingCourcesDiv.InnerHtml += "</table>";
            existingCourcesDiv.InnerHtml += "<div class='page_navigation'></div>";
            existingCourcesDiv.InnerHtml += "</div>";

            if (courseResult.Count <= 0)
            {
                existingCourcesDiv.Visible = false;
            }
            else
            {
                existingCourcesDiv.Visible = true;
            }

            //   uiLitResultsMessage.Text = "Search Results: " + resultsNumber + " out of " + totalCount.ToString() + " results";
        }
        catch (Exception ex) { }
    }
예제 #5
0
    /// <summary>
    /// Populate controls with previous search search criteria
    /// </summary>
    /// <param name="objSearchCriteria"></param>
    private void populateExistingValues(SearchCourse objSearchCriteria)
    {
        if (objSearchCriteria.Keywords != "")
        {
            txtKeyword.Text = objSearchCriteria.Keywords;
        }

        if (objSearchCriteria.StartDate != "")
        {
            txtStartDate.Text = objSearchCriteria.StartDate;
        }

        if (objSearchCriteria.EndDate != "")
        {
            txtEndDate.Text = objSearchCriteria.EndDate;
        }

        if (objSearchCriteria.Subject != "")
        {
            ddlSubject.SelectedValue = objSearchCriteria.Subject;
        }

        if (objSearchCriteria.HSWOnly != "")
        {
            uiChkHealthSafetyWelfare.Checked = true;
        }
        if (objSearchCriteria.DistanceEducationOnly != "")
        {
            uiChkDistanceEducation.Checked = true;
        }
        if (objSearchCriteria.Providers != "")
        {
            string[] providers = objSearchCriteria.Providers.Split(',');
            for (int i = 0; i < providers.Length; i++)
            {
                for (int j = 0; j < lbEducationProvider.Items.Count; j++)
                {
                    if (providers[i] == lbEducationProvider.Items[j].Value)
                    {
                        lbEducationProvider.Items[j].Selected = true;
                        break;
                    }
                }
            }
        }
    }
예제 #6
0
    /// <summary>
    /// Assign existing search criteria selection
    /// </summary>
    /// <param name="objSearch"></param>
    private void loadExistingSelection(SearchCourse objSearch)
    {
        ///Assign keyword
        txtKeyword.Text = objSearch.Keywords;

        ///Check check boxes according to previous selection criteria
        if (objSearch.SearchFields.IndexOf("Title") == -1)
        {
            chkTitle.Checked = false;
        }
        if (objSearch.SearchFields.IndexOf("Description") == -1)
        {
            chkDescription.Checked = false;
        }
        if (objSearch.SearchFields.IndexOf("Outcomes") == -1)
        {
            chkLearningOutcomes.Checked = false;
        }

        ///Select subject
        if (objSearch.Subject.Trim() != string.Empty)
        {
            ddlSubject.SelectedValue = objSearch.Subject.Trim();
        }

        ///Select location
        if (objSearch.Location.Trim() != string.Empty)
        {
            ddlLocation.SelectedValue = objSearch.Location.Trim();
        }

        ///Load start date
        if (objSearch.StartDate != string.Empty)
        {
            txtStartDate.Text = objSearch.StartDate;
        }

        ///Load end date
        if (objSearch.EndDate != string.Empty)
        {
            txtEndDate.Text = objSearch.EndDate;
        }
    }
예제 #7
0
    /// <summary>
    /// Page Load Event to load input fields initially
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Populate Approved Provider ListBox
            populateProviders();

            //Populate Subject Dropdown List
            populateSubjectList();

            //Populate State Dropdown List
            populateStateList();

            ///If Reached this page form Course Search Result page by clicking search again
            ///And having criteria into the session then load existing selection value
            if (Request.QueryString["SearchAgain"] != null && Session[LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA] != null)
            {
                ///Get Search criteria from session
                SearchCourse objSearchCriteria = (SearchCourse)Session[LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA];
                if (objSearchCriteria != null)
                {
                    loadExistingSelection(objSearchCriteria);
                }
            }
            else
            {
                ///Commented this code according to internal acceptance changes
                //Initialize value for start and end date
                //txtStartDate.Text = DateTime.Today.ToString("MM/dd/yyyy");
                //txtEndDate.Text = DateTime.Today.ToString("MM/dd/yyyy");
            }

            ///Focus to the first input control
            txtKeyword.Focus();
        }

        //txtKeyword.Attributes.Add("onclick", "javascript:RemoveDefaultText(this,'Search Here');");

        //chkDistanceEdu.Attributes.Add("onclick", "initializeLocation(this)");
        //ddlLocation.Attributes.Add("onchange", "uncheckDistanceEducation(this)");
    }
예제 #8
0
    /// <summary>
    /// Set Previous Page, Next Page text and link
    /// </summary>
    /// <param name="objSearch"></param>
    /// <param name="totalCount"></param>
    private void setPreviousNextPage(SearchCourse objSearch, int totalCount)
    {
        ///For previous page link
        if (objSearch.PageIndex > 0)
        {
            tdPreviousPage.InnerHtml  = "<a href=\"?" + LACESConstant.QueryString.PAGE_INDEX + "=" + (objSearch.PageIndex - 1) + "\">";
            tdPreviousPage.InnerHtml += "&lt; Previous " + LACESConstant.SEARCH_RESULT_PAGE_SIZE + "</a>";
        }

        ///For next page link
        int remainingRecords = totalCount - ((objSearch.PageIndex + 1) * LACESConstant.SEARCH_RESULT_PAGE_SIZE);

        if (remainingRecords > 0)
        {
            int nextPageSize = LACESConstant.SEARCH_RESULT_PAGE_SIZE;
            if (nextPageSize > remainingRecords)
            {
                nextPageSize = remainingRecords;
            }
            tdNextPage.InnerHtml  = "<a href=\"?" + LACESConstant.QueryString.PAGE_INDEX + "=" + (objSearch.PageIndex + 1) + "\">";
            tdNextPage.InnerHtml += "Next &gt; " + nextPageSize + "</a>";
        }
    }
예제 #9
0
    /// <summary>
    /// Get Search Criteria and redirect to search result page
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnFindCourses_Click(object sender, EventArgs e)
    {
        //string searchCriteria = buildSearchCriteria();
        SearchCourse objSearchCourse = buildSearchCriteria();

        objSearchCourse.SortColumn = "StartDate";
        objSearchCourse.SortOrder  = "DESC";
        using (Utility.ASLA_Laces_ProdEntities item = new Utility.ASLA_Laces_ProdEntities())
        {
            string subject  = ddlSubject.SelectedValue;
            string location = ddlLocation.SelectedValue;
            Utility.LACES_Search_Terms terms = new Utility.LACES_Search_Terms();
            terms.Location     = location;
            terms.SubjectArea  = subject;
            terms.DateSearched = System.DateTime.Now;
            item.LACES_Search_Terms.Add(terms);
            item.SaveChanges();
        }


        //Add search criteria into session
        Session.Add(LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA, objSearchCourse);
        Response.Redirect("~/visitor/CourseResult.aspx");
    }
예제 #10
0
 public ActionResult Search(SearchCourse searchCourse)
 {
     if (searchCourse is object)
     {
         if (lastSearchSetting is object)
         {
             if (searchCourse.DepartmentName != lastSearchSetting.DepartmentName || searchCourse.Grade != lastSearchSetting.Grade || searchCourse.Name != lastSearchSetting.Name)
             {
                 searchCourse.Page = 1;
             }
         }
         lastSearchSetting = searchCourse;
         searchCourse.Page = searchCourse.Page == 0 ? 1 : searchCourse.Page;
         var courses = new List <Course>();
         if (!searchCourse.DepartmentName.IsNullOrWhiteSpace())
         {
             ViewData["DepartmentName"] = searchCourse.DepartmentName;
             var currentDepartment = db.Departments.Where(department => department.Name.Contains(searchCourse.DepartmentName)).FirstOrDefault();
             if (currentDepartment is object)
             {
                 var integerDepartmentId = db.Departments.Where(department => department.Name.Contains(searchCourse.DepartmentName)).FirstOrDefault().Id;
                 courses = db.Courses.Where(course => course.DepartmentId == integerDepartmentId).ToList();
             }
         }
         else
         {
             ViewData["DepartmentName"] = "";
             courses = db.Courses.ToList();
         }
         if (!searchCourse.Grade.IsNullOrWhiteSpace() && searchCourse.Grade != string.Empty)
         {
             ViewData["Grade"] = searchCourse.Grade;
             var integerGrade = int.Parse(searchCourse.Grade);
             if (courses.Count == 0)
             {
                 courses = db.Courses.Where(course => course.Grade == integerGrade).ToList();
             }
             else
             {
                 courses = courses.Where(course => course.Grade == integerGrade).ToList();
             }
         }
         else
         {
             ViewData["Grade"] = "";
         }
         if (!searchCourse.Name.IsNullOrWhiteSpace() && searchCourse.Name != string.Empty)
         {
             ViewData["Name"] = searchCourse.Name;
             if (courses.Count == 0)
             {
                 courses = db.Courses.Where(course => course.Name.Contains(searchCourse.Name)).ToList();
             }
             else
             {
                 courses = courses.Where(course => course.Name.Contains(searchCourse.Name)).ToList();
             }
         }
         else
         {
             ViewData["Name"] = "";
         }
         if (!searchCourse.Teacher.IsNullOrWhiteSpace() && searchCourse.Teacher != string.Empty)
         {
             ViewData["Teacher"] = searchCourse.Teacher;
             if (courses.Count == 0)
             {
                 courses = db.Courses.Where(course => course.Teacher.Contains(searchCourse.Teacher)).ToList();
             }
             else
             {
                 courses = courses.Where(course => course.Teacher.Contains(searchCourse.Teacher)).ToList();
             }
         }
         else
         {
             ViewData["Teacher"] = "";
         }
         var coursesToView = (from course in courses
                              join department in db.Departments on course.DepartmentId equals department.Id
                              select new JointSearchCourse()
         {
             Id = course.Id,
             DepartmentName = department.Name,
             Grade = course.Grade,
             CourseName = course.Name,
             Teacher = course.Teacher,
             Duration = course.Duration,
             Credit = course.Credit,
             Type = course.Type,
             Time = course.Time,
             Location = course.Location,
             Limit = course.Limit,
             Url = course.Url,
             Remark = course.Remark,
             Popularity = course.Popularity
         }).ToList();
         ViewData["OrderType"] = searchCourse.OrderType;
         ViewData["Page"]      = searchCourse.Page;
         Debug.WriteLine(searchCourse.Page);
         return(PartialView(CourseToViewOrder(coursesToView.ToPagedList(searchCourse.Page, PAGE_SIZE).ToList(), searchCourse)));
     }
     else
     {
         ViewData["DepartmentName"] = "";
         ViewData["Grade"]          = "";
         ViewData["Name"]           = "";
         ViewData["Teacher"]        = "";
         ViewData["Page"]           = 1;
         var courses       = db.Courses.ToList();
         var coursesToView = (from course in courses
                              join department in db.Departments on course.DepartmentId equals department.Id
                              select new JointSearchCourse()
         {
             Id = course.Id,
             DepartmentName = department.Name,
             Grade = course.Grade,
             CourseName = course.Name,
             Teacher = course.Teacher,
             Duration = course.Duration,
             Credit = course.Credit,
             Type = course.Type,
             Time = course.Time,
             Location = course.Location,
             Limit = course.Limit,
             Url = course.Url,
             Remark = course.Remark
         }).ToList();
         return(PartialView(CourseToViewOrder(coursesToView.ToPagedList(1, PAGE_SIZE).ToList(), searchCourse)));
     }
 }
예제 #11
0
 public ActionResult PageList(SearchCourse searchCourse)
 {
     return(PartialView(searchCourse));
 }
예제 #12
0
 public ActionResult Index([Bind(Include = "DepartmentName,Grade,Name,Teacher")] SearchCourse searchCourse)
 {
     ViewData["Page"] = searchCourse is object?searchCourse.Page : 1;
     return(RedirectToAction("Search", searchCourse));
 }
예제 #13
0
        private JointSearchCourseToView CourseToViewOrder(List <JointSearchCourse> jointSearchCourseList, SearchCourse searchCourse)
        {
            Debug.WriteLine(jointSearchCourseList.Count);
            switch (searchCourse.OrderType)
            {
            case 1:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderByDescending(courseToView => courseToView.CourseName.Length).ToList(),
                    SearchCourse = searchCourse
                });

            case 2:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderByDescending(courseToView => courseToView.Credit).ToList(),
                    SearchCourse = searchCourse
                });

            case -1:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderBy(courseToView => courseToView.Popularity).ToList(),
                    SearchCourse = searchCourse
                });

            case -2:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderBy(courseToView => courseToView.CourseName.Length).ToList(),
                    SearchCourse = searchCourse
                });

            case -3:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderBy(courseToView => courseToView.Credit).ToList(),
                    SearchCourse = searchCourse
                });

            default:
                return(new JointSearchCourseToView
                {
                    JointSearchCourseList = jointSearchCourseList.OrderByDescending(courseToView => courseToView.Popularity).ToList(),
                    SearchCourse = searchCourse
                });
            }
        }
예제 #14
0
    /// <summary>
    /// Page load event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CourseDataAccess objCourseDAL = new CourseDataAccess();

            ///If search criteria not found in session redirect for select criteria again
            if (Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA] == null)
            {
                //Response.Redirect("WelcomeSearch.aspx");
                Response.Redirect("../Default.aspx");
            }

            lblMessage.Visible = false;

            ///Get Search criteria from session
            SearchCourse objSearchCriteria = (SearchCourse)Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA];


            //Populate Subject Dropdown List
            populateSubjectList();

            //Populate Provider ListBox
            populateProviders();

            populateExistingValues(objSearchCriteria);


            ///Check Sort Column Query String
            ///Currently sorting facility is not available
            //if (Request.QueryString[LACESConstant.QueryString.SORT_COLUMN] != null)
            //{
            //    objSearchCriteria.SortColumn = Request.QueryString[LACESConstant.QueryString.SORT_COLUMN].ToString();
            //}

            ///Check Sort Order Query String
            ///Currently sorting facility is not available
            //if (Request.QueryString[LACESConstant.QueryString.SORT_ORDER] != null)
            //{
            //    objSearchCriteria.SortOrder = Request.QueryString[LACESConstant.QueryString.SORT_ORDER].ToString();
            //}

            ///Check Current Page Index Query String
            if (Request.QueryString[LACESConstant.QueryString.PAGE_INDEX] != null)
            {
                objSearchCriteria.PageIndex = Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PAGE_INDEX].ToString());
            }

            ///Create Header row
            //createHeaderRow(objSearchCriteria.SortColumn, objSearchCriteria.SortOrder);

            ///Adjust left/right content place holder width
            IncreaseLeftContentWidth();

            ///Generate ORDER BY value
            string orderBy = "";
            if (objSearchCriteria.SortColumn.ToLower() == "location")
            {
                orderBy = "[tblCourseDetails].[City] " + objSearchCriteria.SortOrder + ", [tblCourseDetails].[StateProvince] " + objSearchCriteria.SortOrder;
            }
            else
            {
                orderBy = objSearchCriteria.SortColumn + " " + objSearchCriteria.SortOrder;
            }

            int totalCount = 0;

            ///Get Search result by query
            try
            {
                //Debugger.Break();

                courseResult = objCourseDAL.GetPagedCourseBySearch(objSearchCriteria.WhereCondition, objSearchCriteria.PageIndex,
                                                                   LACESConstant.SEARCH_RESULT_PAGE_SIZE, orderBy, ref totalCount);
            }
            catch { }

            ///Show selecterd criteria in right side
            //showSelectedCriteria(objSearchCriteria, totalCount);

            ///Generate PreviousPage NextPage link
            setPreviousNextPage(objSearchCriteria, totalCount);

            ///Store Changed result in the session
            Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA] = objSearchCriteria;
        }
        txtKeyword.Focus();
        txtKeyword.Attributes.Add("onclick", "javascript:RemoveDefaultText(this,'Search Here');");
    }
예제 #15
0
    /// <summary>
    /// Page load event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        CourseDataAccess objCourseDAL = new CourseDataAccess();

        if (!IsPostBack)
        {
            ///If search criteria not found in session redirect for select criteria again
            if (Session[LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA] == null)
            {
                Response.Redirect("FindACourse.aspx");
            }

            lblMessage.Visible = false;

            ///If found CousrseID and Status as query sting then change the status for this course
            if (Request.QueryString[LACESConstant.QueryString.COURSE_ID] != null && Request.QueryString[LACESConstant.QueryString.COURSE_STATUS] != null)
            {
                long   courseId = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.COURSE_ID].ToString());
                string status   = Request.QueryString[LACESConstant.QueryString.COURSE_STATUS].ToString();
                bool   updated  = false;

                ///Open Course
                if (status.ToLower() == "open")
                {
                    updated = objCourseDAL.ChangeCourseStatus(courseId, "OP");
                }
                ///Close Course
                else if (status.ToLower() == "close")
                {
                    updated = objCourseDAL.ChangeCourseStatus(courseId, "CL");
                }

                ///If updated successfully generate success message
                if (updated)
                {
                    Course updatedCourse = objCourseDAL.GetCoursesDetailsByID(courseId);
                    if (updatedCourse.Status == "Open")
                    {
                        updatedCourse.Status = "opened";
                    }
                    else
                    {
                        updatedCourse.Status = "closed";
                    }
                    ///Message store to session
                    Session[LACESConstant.SessionKeys.COURSE_ACTIVE_DEACTIVE_MSG] = "You have " + updatedCourse.Status + " " + Server.HtmlEncode(updatedCourse.Title) + " in the " + LACESConstant.LACES_TEXT + " system.";
                }
                else
                {
                    ///Message store to session
                    Session[LACESConstant.SessionKeys.COURSE_ACTIVE_DEACTIVE_MSG] = "Selected course has been updated by another admin.";
                }

                Response.Redirect("CourseResult.aspx");
            }

            ///If session contain any message, show the message and assign null
            if (Session[LACESConstant.SessionKeys.COURSE_ACTIVE_DEACTIVE_MSG] != null)
            {
                string message = Session[LACESConstant.SessionKeys.COURSE_ACTIVE_DEACTIVE_MSG].ToString();
                lblMessage.Visible = true;
                lblMessage.Text    = message;
                if (message == "Selected course has been updated by another admin.")
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblMessage.ForeColor = System.Drawing.Color.Green;
                }
                Session[LACESConstant.SessionKeys.COURSE_ACTIVE_DEACTIVE_MSG] = null;
            }

            ///Get Search criteria from session
            SearchCourse objSearchCriteria = (SearchCourse)Session[LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA];

            //Populate Subject Dropdown List
            populateSubjectList();

            //Populate Provider ListBox
            populateProviders();

            populateExistingValues(objSearchCriteria);

            ///Check Sort Column Query String
            if (Request.QueryString[LACESConstant.QueryString.SORT_COLUMN] != null)
            {
                objSearchCriteria.SortColumn = Request.QueryString[LACESConstant.QueryString.SORT_COLUMN].ToString();
            }

            ///Check Sort Order Query String
            if (Request.QueryString[LACESConstant.QueryString.SORT_ORDER] != null)
            {
                objSearchCriteria.SortOrder = Request.QueryString[LACESConstant.QueryString.SORT_ORDER].ToString();
            }

            ///Check Current Page Index Query String
            if (Request.QueryString[LACESConstant.QueryString.PAGE_INDEX] != null)
            {
                objSearchCriteria.PageIndex = Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PAGE_INDEX].ToString());
            }

            ///Create Header row
            //createHeaderRow(objSearchCriteria.SortColumn, objSearchCriteria.SortOrder);

            ///Adjust left/right content place holder width
            IncreaseLeftContentWidth();

            ///Generate ORDER BY value
            string orderBy = "";
            if (objSearchCriteria.SortColumn.ToLower() == "location")
            {
                orderBy = "[tblCourseDetails].[City] " + objSearchCriteria.SortOrder + ", [tblCourseDetails].[StateProvince] " + objSearchCriteria.SortOrder;
            }
            else
            {
                orderBy = objSearchCriteria.SortColumn + " " + objSearchCriteria.SortOrder;
            }

            int totalCount = 0;

            ///Get Search result by query
            try
            {
                courseResult = objCourseDAL.GetPagedCourseBySearch(objSearchCriteria.WhereCondition, objSearchCriteria.PageIndex,
                                                                   LACESConstant.SEARCH_RESULT_PAGE_SIZE, orderBy, ref totalCount);
                string resultsNumber = "";
                if (objSearchCriteria.PageIndex == 0)
                {
                    resultsNumber = "1 -";
                }
                else
                {
                    resultsNumber = ((objSearchCriteria.PageIndex * 10) + 1).ToString() + " - ";
                }
                int pageMax = ((objSearchCriteria.PageIndex + 1) * LACESConstant.SEARCH_RESULT_PAGE_SIZE);
                if (pageMax <= totalCount)
                {
                    resultsNumber += ((objSearchCriteria.PageIndex + 1) * 10).ToString();
                }
                else
                {
                    resultsNumber += totalCount.ToString();
                }
                uiLitResultsMessage.Text = "Search Results: " + resultsNumber + " out of " + totalCount.ToString() + " results";
            }
            catch (Exception ex) { }
            ///Show selecterd criteria in right side
            //showSelectedCriteria(objSearchCriteria, totalCount);

            ///Generate PreviousPage NextPage link
            setPreviousNextPage(objSearchCriteria, totalCount);

            ///Store Changed result in the session
            Session[LACESConstant.SessionKeys.SEARCH_COURSE_CRITERIA] = objSearchCriteria;
        }
        txtKeyword.Focus();
        txtKeyword.Attributes.Add("onclick", "javascript:RemoveDefaultText(this,'Search Here');");
    }
        public async Task <ViewResult> Search(string id, string KeyWord)
        {
            ViewData["Id"] = id;

            AppUser currentUser = userManager.Users.FirstOrDefault(u => u.Id == id);

            //users
            List <AppUser> users = new List <AppUser>();

            foreach (AppUser user in userManager.Users.Where(u => u.CompanyName == currentUser.CompanyName))
            {
                if (SearchWordExists(user.FirstName, KeyWord))
                {
                    users.Add(user);
                }
                else if (SearchWordExists(user.LastName, KeyWord))
                {
                    users.Add(user);
                }
                else if (SearchWordExists(user.UserName, KeyWord))
                {
                    users.Add(user);
                }
            }
            SearchAllUsers allUsers = new SearchAllUsers
            {
                AllUsers = users.AsQueryable().OrderBy(u => u.LastName)
                           .Take(MaxSearchPageUsers),
                UserPageInfo = new SearchUserPageInfo
                {
                    CurrentPage  = 1,
                    TotalUsers   = users.AsQueryable().Count(),
                    UsersPerPage = MaxSearchPageUsers
                }
            };

            //courses for ALL USERS
            //& presentations
            List <SearchCourse>         courses         = new List <SearchCourse>();
            List <SearchPresentation>   presentations   = new List <SearchPresentation>();
            List <SearchRepresentation> representations = new List <SearchRepresentation>();
            List <SearchVideo>          videos          = new List <SearchVideo>();
            List <SearchFiles>          files           = new List <SearchFiles>();

            foreach (Course course in repository.Courses.Where(c => c.Status == "Public" &&
                                                               (c.CreatedBy.CompanyName == currentUser.CompanyName ||
                                                                c.CreatedBy.CompanyName == null)))
            {
                if (SearchWordExists(course.Title, KeyWord))
                {
                    SearchCourse searchCourse = new SearchCourse
                    {
                        Course    = course,
                        CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                    };
                    courses.Add(searchCourse);
                }

                //course video
                if (repository.Videos.Any(v => v.Id == course.VideoId))
                {
                    Video courseVideo = repository.Videos.FirstOrDefault(v => v.Id == course.VideoId);
                    if (SearchWordExists(courseVideo.Title, KeyWord))
                    {
                        string info = $"<span class='text-muted'>For: <i class='{course.AwardIcon}'></i>" +
                                      $"<strong>{course.Title}</strong></span>";
                        SearchVideo searchVideoC = new SearchVideo
                        {
                            Video        = courseVideo,
                            CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == courseVideo.CreatedBy),
                            VideoForInfo = info
                        };
                        videos.Add(searchVideoC);
                    }
                }

                foreach (Presentation presentation in course.Presentations)
                {
                    if (SearchWordExists(presentation.Title, KeyWord))
                    {
                        SearchPresentation searchPresentation = new SearchPresentation
                        {
                            Presentation = presentation,
                            Course       = course,
                            CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                        };
                        presentations.Add(searchPresentation);
                    }

                    //presentation video
                    if (repository.Videos.Any(v => v.Id == presentation.VideoId))
                    {
                        Video presentationVideo = repository.Videos.FirstOrDefault(v => v.Id == presentation.VideoId);
                        if (SearchWordExists(presentationVideo.Title, KeyWord))
                        {
                            string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" +
                                          $"<strong>{course.Title}</strong></span>";
                            SearchVideo searchVideoP = new SearchVideo
                            {
                                Video        = presentationVideo,
                                CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == presentationVideo.CreatedBy),
                                VideoForInfo = info
                            };
                            videos.Add(searchVideoP);
                        }
                    }

                    //presentation files
                    foreach (PresentationFiles file1 in repository.PresentationFiles
                             .Where(f => f.PresentationId == presentation.PresentationId))
                    {
                        if (SearchWordExists(file1.Title, KeyWord))
                        {
                            string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" +
                                          $"<strong>{course.Title}</strong></span>";
                            SearchFiles searchFile1 = new SearchFiles
                            {
                                File        = file1,
                                CreatedBy   = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id),
                                FileForInfo = info
                            };
                            files.Add(searchFile1);
                        }
                    }

                    foreach (Representation representation in presentation.Representations)
                    {
                        if (SearchWordExists(representation.Title, KeyWord))
                        {
                            SearchRepresentation searchRepresentation = new SearchRepresentation
                            {
                                Representation    = representation,
                                PresentationTitle = presentation.Title,
                                Course            = course,
                                Video             = repository.Videos.FirstOrDefault(v => v.Id == representation.VideoId),
                                CreatedBy         = userManager.Users.FirstOrDefault(u => u.Id == representation.CreatedBy.Id)
                            };
                            representations.Add(searchRepresentation);
                        }

                        //representation video
                        if (repository.Videos.Any(v => v.Id == representation.VideoId))
                        {
                            Video representationVideo = repository.Videos.FirstOrDefault(v => v.Id == representation.VideoId);
                            if (SearchWordExists(representationVideo.Title, KeyWord))
                            {
                                if (repository.VideoShareds.Any(v => v.UserId == currentUser.Id &&
                                                                v.VideoId == representationVideo.Id) ||
                                    await userManager.IsInRoleAsync(currentUser, "Admin") == true ||
                                    await userManager.IsInRoleAsync(currentUser, "Manager") == true ||
                                    representationVideo.CreatedBy == currentUser.Id)
                                {
                                    string info = $"<span class='text-muted'>For: <strong>{representation.Title}</strong> <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" +
                                                  $"<strong>{course.Title}</strong></span>";
                                    SearchVideo searchVideoR = new SearchVideo
                                    {
                                        Video        = representationVideo,
                                        CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == representationVideo.CreatedBy),
                                        VideoForInfo = info
                                    };
                                    videos.Add(searchVideoR);
                                }
                            }
                        }
                    }
                }
            }

            //courses where currentUser == course.CreatedBy && status == "Private"
            //& presentations
            foreach (Course course in repository.Courses.Where(c => c.Status == "Private" &&
                                                               (c.CreatedBy.CompanyName == currentUser.CompanyName ||
                                                                c.CreatedBy.CompanyName == null)))
            {
                if (course.CreatedBy != null)
                {
                    if (course.CreatedBy.Id == currentUser.Id)
                    {
                        if (SearchWordExists(course.Title, KeyWord))
                        {
                            SearchCourse searchCourse = new SearchCourse
                            {
                                Course    = course,
                                CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                            };
                            courses.Add(searchCourse);
                        }

                        //course video
                        if (repository.Videos.Any(v => v.Id == course.VideoId))
                        {
                            Video courseVideo = repository.Videos.FirstOrDefault(v => v.Id == course.VideoId);
                            if (SearchWordExists(courseVideo.Title, KeyWord))
                            {
                                string info = $"<span class='text-muted'>For: <i class='{course.AwardIcon}'></i>" +
                                              $"<strong>{course.Title}</strong></span>";
                                SearchVideo searchVideoC = new SearchVideo
                                {
                                    Video        = courseVideo,
                                    CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == courseVideo.CreatedBy),
                                    VideoForInfo = info
                                };
                                videos.Add(searchVideoC);
                            }
                        }

                        foreach (Presentation presentation in course.Presentations)
                        {
                            if (SearchWordExists(presentation.Title, KeyWord))
                            {
                                SearchPresentation searchPresentation = new SearchPresentation
                                {
                                    Presentation = presentation,
                                    Course       = course,
                                    CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id)
                                };
                                presentations.Add(searchPresentation);
                            }

                            //presentation video
                            if (repository.Videos.Any(v => v.Id == presentation.VideoId))
                            {
                                Video presentationVideo = repository.Videos.FirstOrDefault(v => v.Id == presentation.VideoId);
                                if (SearchWordExists(presentationVideo.Title, KeyWord))
                                {
                                    string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" +
                                                  $"<strong>{course.Title}</strong></span>";
                                    SearchVideo searchVideoP = new SearchVideo
                                    {
                                        Video        = presentationVideo,
                                        CreatedBy    = userManager.Users.FirstOrDefault(u => u.Id == presentationVideo.CreatedBy),
                                        VideoForInfo = info
                                    };
                                    videos.Add(searchVideoP);
                                }
                            }

                            //presentation files
                            foreach (PresentationFiles file2 in repository.PresentationFiles
                                     .Where(f => f.PresentationId == presentation.PresentationId))
                            {
                                if (SearchWordExists(file2.Title, KeyWord))
                                {
                                    string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" +
                                                  $"<strong>{course.Title}</strong></span>";
                                    SearchFiles searchFile2 = new SearchFiles
                                    {
                                        File        = file2,
                                        CreatedBy   = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id),
                                        FileForInfo = info
                                    };
                                    files.Add(searchFile2);
                                }
                            }
                        }
                    }
                }
            }
            SearchAllCourses allCourses = new SearchAllCourses
            {
                AllCourses = courses.AsQueryable().OrderBy(c => c.Course.Title)
                             .Take(MaxSearchPageCourse),
                CoursePageInfo = new SearchCoursePageInfo
                {
                    CurrentPage    = 1,
                    TotalCourses   = courses.AsQueryable().Count(),
                    CoursesPerPage = MaxSearchPageCourse
                }
            };
            SearchAllPresentation allPresentation = new SearchAllPresentation
            {
                AllPresentations = presentations.AsQueryable()
                                   .OrderBy(p => p.Presentation.Title)
                                   .Take(MaxSearchPagePresentation),
                PresentationPageInfo = new SearchPresentationPageInfo
                {
                    CurrentPage          = 1,
                    TotalPresentations   = presentations.AsQueryable().Count(),
                    PresentationsPerPage = MaxSearchPagePresentation
                }
            };
            SearchAllRepresentation allRepresentation = new SearchAllRepresentation
            {
                AllRepresentation = representations.AsQueryable()
                                    .OrderBy(r => r.Representation.Title)
                                    .Take(MaxSearchPageRepresentation),
                RepresentationPageInfo = new SearchRepresentationPageInfo
                {
                    CurrentPage           = 1,
                    TotalRepresentation   = representations.AsQueryable().Count(),
                    RepresentationPerPage = MaxSearchPageRepresentation
                }
            };
            SearchAllVideos allVideos = new SearchAllVideos
            {
                AllVideos = videos.AsQueryable()
                            .OrderBy(v => v.Video.Title)
                            .Take(MaxSearchPageVideo),
                VideoPageInfo = new SearchVideoPageInfo
                {
                    CurrentPage   = 1,
                    TotalVideos   = videos.Count(),
                    VideosPerPage = MaxSearchPageVideo
                }
            };
            SearchAllFiles allFiles = new SearchAllFiles
            {
                AllFiles = files.AsQueryable()
                           .OrderBy(f => f.File.Title)
                           .Take(MaxSearchPageFile),
                FilePageInfo = new SearchFilesPageInfo
                {
                    CurrentPage  = 1,
                    TotalFiles   = files.Count(),
                    FilesPerPage = MaxSearchPageFile
                }
            };

            return(View("Search", new SearchViewModel
            {
                KeyWord = KeyWord,
                Users = allUsers,
                Courses = allCourses,
                Presentations = allPresentation,
                Representations = allRepresentation,
                Videos = allVideos,
                Files = allFiles
            }));
        }
예제 #17
0
    /// <summary>
    /// Generate Search criteria from user selection
    /// </summary>
    /// <returns></returns>
    private SearchCourse buildSearchCriteria()
    {
        SearchCourse objSearchCourse = new SearchCourse();

        objSearchCourse.Keywords = txtKeyword.Text.Trim();

        ///Split search keword using space
        string[] kewords     = objSearchCourse.Keywords.Replace("'", "''").Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        string   searchQuery = "";

        ///Criteria for Title field
        if (chkTitle.Checked)
        {
            string titleQuery = "";

            ///If having double quotes consider exact match
            if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
            {
                string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
                titleQuery += "[Title] LIKE '" + exactText.Replace("'", "''") + "%' OR [Title] LIKE '% " + exactText.Replace("'", "''") + "%'";
            }
            else
            {
                ///Loop for every keyword
                foreach (string keyword in kewords)
                {
                    if (titleQuery != "")
                    {
                        titleQuery += " OR ";
                    }
                    titleQuery += "[Title] LIKE '" + keyword + "%' OR [Title] LIKE '% " + keyword + "%'";
                }
            }
            searchQuery += titleQuery;
            objSearchCourse.SearchFields = "Title";
        }

        ///Criteria for Description field
        if (chkDescription.Checked)
        {
            string descriptionQuery = "";

            ///If having double quotes consider exact match
            if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
            {
                string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
                descriptionQuery += "[Description] LIKE '%" + exactText.Replace("'", "''") + "%'";
            }
            else
            {
                ///Loop for every keyword
                foreach (string keyword in kewords)
                {
                    if (descriptionQuery != "")
                    {
                        descriptionQuery += " OR ";
                    }
                    descriptionQuery += "[Description] LIKE '%" + keyword + "%'";
                }
            }

            if (searchQuery != "")
            {
                searchQuery += " OR ";
            }
            searchQuery += descriptionQuery;

            if (objSearchCourse.SearchFields != "")
            {
                objSearchCourse.SearchFields += " / ";
            }
            objSearchCourse.SearchFields += "Description";
        }

        ///Criteria for LearningOutcomes field
        if (chkLearningOutcomes.Checked)
        {
            string lOQuery = "";

            ///If having double quotes consider exact match
            if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
            {
                string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
                lOQuery += "[LearningOutcomes] LIKE '%" + exactText.Replace("'", "''") + "%'";
            }
            else
            {
                ///Loop for every keyword
                foreach (string keyword in kewords)
                {
                    if (lOQuery != "")
                    {
                        lOQuery += " OR ";
                    }
                    lOQuery += "[LearningOutcomes] LIKE '%" + keyword + "%'";
                }
            }

            if (searchQuery != "")
            {
                searchQuery += " OR ";
            }
            searchQuery += lOQuery;

            if (objSearchCourse.SearchFields != "")
            {
                objSearchCourse.SearchFields += " / ";
            }
            objSearchCourse.SearchFields += "Outcomes";
        }

        if (searchQuery != "")
        {
            searchQuery = "(" + searchQuery + ")";
        }

        ///Criteria for Subject Area
        if (ddlSubject.SelectedIndex > 0)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery            += "[Subjects] LIKE '%" + ddlSubject.SelectedValue + "%'";
            objSearchCourse.Subject = ddlSubject.SelectedValue;
        }

        ///Criteria for Distance Education
        if (chkDistanceEdu.Checked)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[DistanceEducation] = 'Y'";
            objSearchCourse.Location = "Distance Education";
        }

        ///Criteria for Location
        else if (ddlLocation.SelectedIndex > 0)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[tblCourseDetails].[StateProvince] = '" + ddlLocation.SelectedValue + "'";
            objSearchCourse.Location = ddlLocation.SelectedValue;
        }

        ///Criteria for Start Date
        if (txtStartDate.Text.Trim() != string.Empty)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[StartDate] >= '" + txtStartDate.Text.Trim() + "'";
            objSearchCourse.StartDate = txtStartDate.Text.Trim();
        }

        ///Criteria for End Date
        if (txtEndDate.Text.Trim() != string.Empty)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery            += "[EndDate] <= '" + txtEndDate.Text.Trim() + "'";
            objSearchCourse.EndDate = txtEndDate.Text.Trim();
        }

        if (searchQuery == "")
        {
            searchQuery = "[tblCourseDetails].[Status] = 'OP' AND [StartDate] >= '" + DateTime.Today + "' AND [tblApprovedProvider].[Status] = 'Active'";
        }
        else
        {
            searchQuery += " AND ([tblCourseDetails].[Status] = 'OP' AND [StartDate] >= '" + DateTime.Today + "' AND [tblApprovedProvider].[Status] = 'Active')";
        }

        objSearchCourse.WhereCondition = searchQuery;
        return(objSearchCourse);
    }
예제 #18
0
    /// <summary>
    /// Page Load Event to load input fields initially
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlMeta htmlGoogleMeta = new HtmlMeta();

        htmlGoogleMeta.Attributes.Add("name", "google-site-verification");
        htmlGoogleMeta.Attributes.Add("content", "K6O__N94_Ynv_-1cyXov5nLAP0Hej6PqelOB22oi4kY");
        Header.Controls.Add(htmlGoogleMeta);
        //redirect users to their respective section home page
        //RedirectToSectionSpecificDefaultPage();
        uiLnkApplicationForm.HRef = GetPDFURL(LACESUtilities.GetApplicationConstants("ApplicationFormPDF"));

        checkLoggedInProvider();

        //change the footer image path
        //  Master.ChangeFooterImagePath = "";

        //set the approved provider link
        string appString = "ApprovedProviderGuidelines.aspx";

        if (appString != "")
        {
            approvedProLink.Attributes["href"] = appString;
        }

        if (!IsPostBack)
        {
            //get all approved providers
            IList <ApprovedProvider>   oApprovedProviders;
            ApprovedProviderDataAccess oApprovedProviderDataAccess = new ApprovedProviderDataAccess();
            int totalCount = 0;
            oApprovedProviders = oApprovedProviderDataAccess.GetPagedApprovedProviderSearch("tblApprovedProvider.Status = 'Active'", 0, Int16.MaxValue, "OrganizationName", "asc", ref totalCount);

            foreach (ApprovedProvider ap in oApprovedProviders)
            {
                string orgName = ap.OrganizationName;
                if (orgName.Length > 48)
                {
                    orgName = orgName.Substring(0, 45) + "...";
                }
                lbEducationProvider.Items.Add(new ListItem(orgName, ap.ID.ToString()));
            }

            //Populate Subject Dropdown List
            populateSubjectList();

            //Populate State Dropdown List
            populateStateList();

            populateSlideshow();
            ///If Reached this page form Course Search Result page by clicking search again
            ///And having criteria into the session then load existing selection value at the visitor section
            if (Request.QueryString["SearchAgain"] != null && Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA] != null)
            {
                ///Get Search criteria from session
                SearchCourse objSearchCriteria = (SearchCourse)Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA];
                if (objSearchCriteria != null)
                {
                    loadExistingSelection(objSearchCriteria);
                }
            }

            ///Focus to the first input control
            txtKeyword.Focus();
        }

        //txtKeyword.Attributes.Add("onclick", "javascript:RemoveDefaultText(this,'Search Here');");

        //chkDistanceEdu.Attributes.Add("onclick", "initializeLocation(this)");
        //ddlLocation.Attributes.Add("onchange", "uncheckDistanceEducation(this)");
    }
예제 #19
0
    /// <summary>
    /// Generate Search criteria from user selection
    /// </summary>
    /// <returns></returns>
    private SearchCourse buildSearchCriteria()
    {
        SearchCourse objSearchCourse = new SearchCourse();

        objSearchCourse.Keywords = txtKeyword.Text.Trim();

        ///Split search keword using space
        string[] kewords     = objSearchCourse.Keywords.Replace("'", "''").Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        string   searchQuery = "";

        ///Criteria for Title field

        string titleQuery = "";

        ///If having double quotes consider exact match
        if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
        {
            string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
            titleQuery += "[Title] LIKE '" + exactText.Replace("'", "''") + "%' OR [Title] LIKE '% " + exactText.Replace("'", "''") + "%'";
        }
        else
        {
            ///Loop for every keyword
            foreach (string keyword in kewords)
            {
                if (titleQuery != "")
                {
                    titleQuery += " OR ";
                }
                titleQuery += "[Title] LIKE '" + keyword + "%' OR [Title] LIKE '% " + keyword + "%'";
            }
        }
        searchQuery += titleQuery;
        objSearchCourse.SearchFields = "Title";


        ///Criteria for Description field

        string descriptionQuery = "";

        ///If having double quotes consider exact match
        if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
        {
            string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
            descriptionQuery += "[Description] LIKE '%" + exactText.Replace("'", "''") + "%'";
        }
        else
        {
            ///Loop for every keyword
            foreach (string keyword in kewords)
            {
                if (descriptionQuery != "")
                {
                    descriptionQuery += " OR ";
                }
                descriptionQuery += "[Description] LIKE '%" + keyword + "%'";
            }
        }

        if (searchQuery != "")
        {
            searchQuery += " OR ";
        }
        searchQuery += descriptionQuery;

        if (objSearchCourse.SearchFields != "")
        {
            objSearchCourse.SearchFields += " / ";
        }
        objSearchCourse.SearchFields += "Description";


        ///Criteria for LearningOutcomes field
        string lOQuery = "";

        ///If having double quotes consider exact match
        if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
        {
            string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
            lOQuery += "[LearningOutcomes] LIKE '%" + exactText.Replace("'", "''") + "%'";
        }
        else
        {
            ///Loop for every keyword
            foreach (string keyword in kewords)
            {
                if (lOQuery != "")
                {
                    lOQuery += " OR ";
                }
                lOQuery += "[LearningOutcomes] LIKE '%" + keyword + "%'";
            }
        }

        if (searchQuery != "")
        {
            searchQuery += " OR ";
        }
        searchQuery += lOQuery;

        if (objSearchCourse.SearchFields != "")
        {
            objSearchCourse.SearchFields += " / ";
        }
        objSearchCourse.SearchFields += "Outcomes";


        if (searchQuery != "")
        {
            searchQuery = "(" + searchQuery + ")";
        }

        ///Criteria for Subject Area
        if (ddlSubject.SelectedIndex > 0)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery            += "[Subjects] LIKE '%" + ddlSubject.SelectedValue + "%'";
            objSearchCourse.Subject = ddlSubject.SelectedValue;
        }

        ///Criteria for Distance Education
        //if (searchQuery != "")
        //    searchQuery += " AND ";
        //searchQuery += "[DistanceEducation] = 'Y'";
        //objSearchCourse.Location = "Distance Education";

        ///Criteria for Location
        if (ddlLocation.SelectedIndex > 0)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[tblCourseDetails].[StateProvince] = '" + ddlLocation.SelectedValue + "'";
            objSearchCourse.Location = ddlLocation.SelectedValue;
        }

        // search for educational provider
        string eduList = "";

        for (int i = 0; i < lbEducationProvider.Items.Count; i++)
        {
            if (lbEducationProvider.Items[i].Selected)
            {
                if (eduList != "")
                {
                    eduList += " OR ";
                }
                eduList += "tblApprovedProvider.[ID] = '" + lbEducationProvider.Items[i].Value + "'";
                objSearchCourse.Providers += "," + lbEducationProvider.Items[i].Value;
            }
        }
        if (eduList != "")
        {
            if (searchQuery != "")
            {
                searchQuery += " AND (" + eduList + ")";
            }
            else
            {
                searchQuery += "(" + eduList + ")";
            }

            objSearchCourse.Providers = objSearchCourse.Providers.Substring(1);
        }
        if (txtStartDate.Text.Trim() != string.Empty && txtEndDate.Text.Trim() != string.Empty)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[StartDate] <= '" + txtEndDate.Text.Trim() + "' AND [EndDate] >='" + txtStartDate.Text.Trim() + "'";
        }
        else
        {
            ///Criteria for Start Date
            if (txtStartDate.Text.Trim() != string.Empty)
            {
                if (searchQuery != "")
                {
                    searchQuery += " AND ";
                }
                searchQuery += "[StartDate] >= '" + txtStartDate.Text.Trim() + "'";
                objSearchCourse.StartDate = txtStartDate.Text.Trim();
            }

            ///Criteria for End Date
            if (txtEndDate.Text.Trim() != string.Empty)
            {
                if (searchQuery != "")
                {
                    searchQuery += " AND ";
                }
                searchQuery            += "[EndDate] <= '" + txtEndDate.Text.Trim() + "'";
                objSearchCourse.EndDate = txtEndDate.Text.Trim();
            }
        }
        if (uiChkDistanceEducation.Checked)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[DistanceEducation] >= 'Y'";
            objSearchCourse.DistanceEducationOnly = "Y";
        }
        if (uiChkHealthSafetyWelfare.Checked)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery            += "[Health] >= 'Yes'";
            objSearchCourse.HSWOnly = "Yes";
        }
        //Debugger.Break();

        if (searchQuery == "")
        {
            searchQuery = "[tblCourseDetails].[Status] = 'OP' AND [EndDate] >= '" + DateTime.Today + "' AND [tblApprovedProvider].[Status] = 'Active' AND [Active]='T'";
        }
        else
        {
            searchQuery += " AND ([tblCourseDetails].[Status] = 'OP' AND [EndDate] >= '" + DateTime.Today + "' AND [tblApprovedProvider].[Status] = 'Active' AND [Active]='T')";
        }

        objSearchCourse.WhereCondition = searchQuery;
        return(objSearchCourse);
    }
예제 #20
0
    private SearchCourse buildSearchCriteria()
    {
        SearchCourse objSearchCourse = new SearchCourse();

        objSearchCourse.Keywords = txtKeyword.Text.Trim();

        ///Split search keword using space
        string[] kewords     = objSearchCourse.Keywords.Replace("'", "''").Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        string   searchQuery = "";

        ///Criteria for Title field

        string titleQuery = "";

        ///If having double quotes consider exact match
        if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
        {
            string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
            titleQuery += "[Title] LIKE '" + exactText.Replace("'", "''") + "%' OR [Title] LIKE '% " + exactText.Replace("'", "''") + "%'";
        }
        else
        {
            ///Loop for every keyword
            foreach (string keyword in kewords)
            {
                if (titleQuery != "")
                {
                    titleQuery += " OR ";
                }
                titleQuery += "[Title] LIKE '" + keyword + "%' OR [Title] LIKE '% " + keyword + "%'";
            }
        }
        searchQuery += titleQuery;
        objSearchCourse.SearchFields = "Title";


        ///Criteria for Description field
        string descriptionQuery = "";

        ///If having double quotes consider exact match
        if (objSearchCourse.Keywords.StartsWith("\"") && objSearchCourse.Keywords.EndsWith("\""))
        {
            string exactText = objSearchCourse.Keywords.Substring(1, objSearchCourse.Keywords.Length - 2);
            descriptionQuery += "[Description] LIKE '%" + exactText.Replace("'", "''") + "%'";
        }
        else
        {
            ///Loop for every keyword
            foreach (string keyword in kewords)
            {
                if (descriptionQuery != "")
                {
                    descriptionQuery += " OR ";
                }
                descriptionQuery += "[Description] LIKE '%" + keyword + "%'";
            }
        }

        if (searchQuery != "")
        {
            searchQuery += " OR ";
        }
        searchQuery += descriptionQuery;

        if (objSearchCourse.SearchFields != "")
        {
            objSearchCourse.SearchFields += " / ";
        }
        objSearchCourse.SearchFields += "Description";
        if (searchQuery != "")
        {
            searchQuery = "(" + searchQuery + ")";
        }
        ///Criteria for Start Date
        if (txtStartDate.Text.Trim() != string.Empty)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery += "[StartDate] >= '" + txtStartDate.Text.Trim() + "'";
            objSearchCourse.StartDate = txtStartDate.Text.Trim();
        }

        ///Criteria for End Date
        if (txtEndDate.Text.Trim() != string.Empty)
        {
            if (searchQuery != "")
            {
                searchQuery += " AND ";
            }
            searchQuery            += "[EndDate] <= '" + txtEndDate.Text.Trim() + "'";
            objSearchCourse.EndDate = txtEndDate.Text.Trim();
        }

        if (searchQuery == "")
        {
            searchQuery = " 1 = 1 ";
        }

        objSearchCourse.WhereCondition = searchQuery;
        return(objSearchCourse);
    }
예제 #21
0
    /// <summary>
    /// Page load event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CourseDataAccess objCourseDAL = new CourseDataAccess();


            lblMessage.Visible = false;

            ///Get Search criteria from session
            SearchCourse objSearchCriteria = (SearchCourse)Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA];


            //Populate Subject Dropdown List
            populateSubjectList();

            //Populate Provider ListBox
            populateProviders();
            if (objSearchCriteria != null)
            {
                populateExistingValues(objSearchCriteria);


                if (Request.QueryString[LACESConstant.QueryString.PAGE_INDEX] != null)
                {
                    objSearchCriteria.PageIndex = Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PAGE_INDEX].ToString());
                }

                string orderBy = "";
                if (objSearchCriteria.SortColumn.ToLower() == "location")
                {
                    orderBy = "[tblCourseDetails].[City] " + objSearchCriteria.SortOrder + ", [tblCourseDetails].[StateProvince] " + objSearchCriteria.SortOrder;
                }
                else
                {
                    orderBy = objSearchCriteria.SortColumn + " " + objSearchCriteria.SortOrder;
                }

                int totalCount = 0;

                ///Get Search result by query
                try
                {
                    //Debugger.Break();

                    courseResult = objCourseDAL.GetPagedCourseBySearch(objSearchCriteria.WhereCondition, objSearchCriteria.PageIndex,
                                                                       LACESConstant.SEARCH_RESULT_PAGE_SIZE, orderBy, ref totalCount);
                    uiRptCourseSearchResults.DataSource = courseResult;
                    uiRptCourseSearchResults.DataBind();
                    //int pagenumber = ;
                    string resultsNumber = "";
                    if (objSearchCriteria.PageIndex == 0)
                    {
                        resultsNumber = "1 -";
                    }
                    else
                    {
                        resultsNumber = ((objSearchCriteria.PageIndex * 10) + 1).ToString() + " - ";
                    }
                    int pageMax = ((objSearchCriteria.PageIndex + 1) * LACESConstant.SEARCH_RESULT_PAGE_SIZE);
                    if (pageMax <= totalCount)
                    {
                        resultsNumber += ((objSearchCriteria.PageIndex + 1) * 10).ToString();
                    }
                    else
                    {
                        resultsNumber += totalCount.ToString();
                    }
                    uiLitResultsMessage.Text = resultsNumber + " out of " + totalCount.ToString();
                }
                catch (Exception ex)
                {
                    string t = ex.Message;
                }

                setPreviousNextPage(objSearchCriteria, totalCount);

                ///Store Changed result in the session
                Session[LACESConstant.SessionKeys.SEARCH_VISITOR_CRITERIA] = objSearchCriteria;
            }
            txtKeyword.Focus();
            txtKeyword.Attributes.Add("onclick", "javascript:RemoveDefaultText(this,'Search Here');");
        }
    }