public async Task <IHttpActionResult> LoadStudent(SearchStudentViewModel info)
        {
            #region Parameter validation

            if (info == null)
            {
                info = new SearchStudentViewModel();
                Validate(info);
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            #endregion

            // Get all student from database
            var students = UnitOfWork.RepositoryStudent.Search();

            // Id have been defined
            if (info.Ids != null && info.Ids.Count > 0)
            {
                info.Ids = info.Ids.Where(x => x > 0).ToList();
                if (info.Ids != null && info.Ids.Count > 0)
                {
                    students = students.Where(x => info.Ids.Contains(x.Id));
                }
            }

            // Name have been defined
            if (info.Usernames != null && info.Usernames.Count > 0)
            {
                info.Usernames = info.Usernames.Where(x => !string.IsNullOrEmpty(x)).ToList();
                if (info.Usernames.Count > 0)
                {
                    students = students.Where(x => info.Usernames.Any(y => x.Username.Contains(y)));
                }
            }

            // Statuses have been defined.
            if (info.Statuses != null && info.Statuses.Count > 0)
            {
                info.Statuses =
                    info.Statuses.Where(x => Enum.IsDefined(typeof(MasterItemStatus), x)).ToList();
                if (info.Statuses.Count > 0)
                {
                    students = students.Where(x => info.Statuses.Contains(x.Status));
                }
            }

            // Do sorting.
            var sorting = info.Sort;
            if (sorting != null)
            {
                students = UnitOfWork.Sort(students, sorting.Direction, sorting.Property);
            }
            else
            {
                students = UnitOfWork.Sort(students, SortDirection.Ascending,
                                           StudentPropertySort.Username);
            }

            // Paginate.
            var result = new SearchResult <IList <Database.Models.Entities.Student> >
            {
                Total   = students.Count(),
                Records = await UnitOfWork.Paginate(students, info.Pagination).ToListAsync()
            };

            return(Ok(result));
        }
 public SearchStudentDialog()
 {
     InitializeComponent();
     DataContext = new SearchStudentViewModel();
 }