public string[] GetUnassignedUsersList(string prefixText, int count)
 {
     using (var helper = new DbHelper.Classes())
     {
         //var user = UserId;
         var user = Page.User as CustomPrincipal;
         if (user != null)
         {
             var asglist = (ViewState["enrolledList"] as List <Academic.ViewModel.UserClassViewModel>)
                           ?? new List <UserClassViewModel>();
             //if (asglist == null)
             //    asglist =
             return(helper.ListUsersNotInSubjectSession(
                        SubjectSessionId
                        , asglist.Select(x => x.Id).ToList()
                        , user.SchoolId
                        , EnrollType
                        ).Select(x => x.FirstName
                                 + (string.IsNullOrEmpty(x.MiddleName) ? "" : " " + x.MiddleName)
                                 + (string.IsNullOrEmpty(x.LastName) ? "" : " " + x.LastName))
                    .Where(x => x.StartsWith(prefixText))
                    .ToArray());
             //+ x.LastName);
         }
         return(new string[] { });//List<string>();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["enrolledList"] = new List <UserClassViewModel>();
                var user = Page.User as CustomPrincipal;
                if (user != null)
                {
                    UserId = user.Id;
                    //============================ populate data in dropdownlist ===========//


                    var enrollmentDuration = new List <IdAndName>();
                    enrollmentDuration.Add(new IdAndName()
                    {
                        Id = 0, Name = "Unlimited"
                    });
                    enrollmentDuration.Add(new IdAndName()
                    {
                        Id = 1, Name = "1 day"
                    });

                    for (int i = 2; i <= 365; i++)
                    {
                        enrollmentDuration.Add(new IdAndName()
                        {
                            Id = i, Name = i + " days"
                        });
                    }

                    ddlEnrollmentDuration.DataSource = enrollmentDuration;
                    ddlEnrollmentDuration.DataBind();

                    //=================== End of Data population =======================//



                    using (var helper = new DbHelper.Classes())
                    {
                        ddlEnrollmentDuration.Enabled = false;
                        //var subsession = helper.GetSubjectSession()
                        var session = helper.GetSubjectSession(SubjectSessionId);

                        if (session == null)
                        {
                            Response.Redirect("~/Views/Course/");
                            return;
                        }

                        var role = GetRole(session, user);

                        if (role == "")
                        {
                            Response.Redirect("~/Views/Class/CourseClassDetail.aspx?ccId=" + session.Id);
                            return;
                        }


                        DbHelper.ComboLoader.LoadRoleForUserEnroll(ref ddlAssignRole, user.SchoolId, role);

                        hidSessionStartDate.Value = ((session.StartDate == null)
                            ? DateTime.Now.ToShortDateString()
                            : session.StartDate.Value.ToShortDateString());
                        var startingFrom = new List <IdAndName>()
                        {
                            new IdAndName()
                            {
                                Id = 0, Name = "Class Start Day (" + ((session.StartDate == null)?"not set":session.StartDate.Value.ToShortDateString()) + ")"
                            }
                            , new IdAndName()
                            {
                                Id = 1, Name = "Today " + DateTime.Now.ToShortDateString()
                            }
                        };
                        ddlStartingFrom.DataSource = startingFrom;
                        ddlStartingFrom.DataBind();


                        var asglist = helper.ListUsersOfSubjectSession(SubjectSessionId);
                        lstAsg.DataSource = asglist;
                        lstAsg.DataBind();

                        ViewState["enrolledList"] = helper.ListSessionUsers(SubjectSessionId);

                        var notasgList = helper.ListUsersNotInSubjectSession(
                            SubjectSessionId
                            , asglist.Select(x => x.Id).ToList()
                            , user.SchoolId
                            , EnrollType);
                        lstUnAsg.DataSource = notasgList;
                        lstUnAsg.DataSource = notasgList;
                        lstUnAsg.DataBind();

                        //AutoCompleteExtender1.ServiceMethod = "GetUnassignedUsersList";

                        //group populate
                        if (session.HasGrouping)
                        {
                            pnlGroup.Visible    = true;
                            ddlGroup.DataSource = session.SubjectClassGrouping.ToList();
                            ddlGroup.DataBind();
                        }
                        else
                        {
                            pnlGroup.Visible = false;
                        }
                    }
                    //DbHelper.ComboLoader.LoadStudentGroup(ref cmbGroup,
                    //    user.SchoolId, true, GroupId);
                    //SchoolId = user.SchoolId;
                    //lstUnAsg.DataSource =
                }
            }
            else
            {
            }
            //DateChooser1.Validate = false;
        }