public IEnumerable<IssueReplyModel> GetReplysToIssue(Issue anIssue, IEnumerable<string> aSelectedRoles, PersonFilter aFilter)
        {
            IEnumerable<IssueReplyDisposition> myIssueReplyDispositions = theEntities.IssueReplyDispositions;

            return (from ir in theEntities.IssueReplys.Include("IssueReplyComments")
                    join u in theEntities.Users on ir.User.Id equals u.Id
                    join ur in theEntities.UserRoles on u.Id equals ur.User.Id
                    join r in theEntities.Roles on ur.Role.Id equals r.Id
                    where ir.Issue.Id == anIssue.Id
                    && aSelectedRoles.Contains(r.Name)
                    && ir.Deleted == false
                    select new IssueReplyModel {
                        Id = ir.Id,
                        Issue = ir.Issue,
                        IssueStance = ir.Disposition,
                        User = u,
                        Reply = ir.Reply,
                        FirstName = ir.TempFirstName,
                        LastName = ir.TempLastName,
                        DateTimeStamp = ir.DateTimeStamp,
                        CommentCount = ir.IssueReplyComments.Where(cc => cc.Deleted == false).Count(),
                        HasDisposition = false,
                        TempDispositionHolder = ir.Disposition,
                        TempPersonFilterHolder = (int)aFilter,
                        TotalAgrees = (from d in ir.IssueReplyDispositions where ir.Disposition == (int)IssueStanceFilter.Agree select d).Count<IssueReplyDisposition>(),
                        TotalDisagrees = (from d in ir.IssueReplyDispositions where ir.Disposition == (int)IssueStanceFilter.Disagree select d).Count<IssueReplyDisposition>()
                    }).ToList<IssueReplyModel>();
        }
Exemple #2
0
        public void QuerySimple(List <PersonEntity> source, PersonFilter filter, int recordCount, string message)
        {
            var result = Specification.Build(source, filter);

            result.Count().Should().Be(recordCount, message);
        }
 public static string PersonFilterButton(PersonFilter aFilter, Dictionary<string, string> aSelectedFilters, string aDisplayName, string aNonSelectedCssClass, string aSelectedCssClass, int aSourceId)
 {
     return Filter("PersonFilter", "FilterIssueByPersonFilter", aFilter.ToString(), aSelectedFilters, aDisplayName, aNonSelectedCssClass, aSelectedCssClass, aSourceId);
 }
Exemple #4
0
        public static IQueryable <Person> ApplyFilter(this IQueryable <Person> query, PersonFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException();
            }

            var where = PredicateBuilder.True <Person>();


            if (!string.IsNullOrEmpty(filter.FirstName))
            {
                where = where.AndAlso(x => x.FirstName.Contains(filter.FirstName));
            }
            if (!string.IsNullOrEmpty(filter.LastName))
            {
                where = where.AndAlso(x => x.LastName.Contains(x.LastName));
            }

            //if (filter.Age != null)
            //{
            //    where = where.AndAlso(x => x.Age == filter.Age);
            //}

            Func <IQueryable <Person>, IOrderedQueryable <Person> > orderBy = null;

            if (!string.IsNullOrEmpty(filter.SortColumn))
            {
                if (filter.IsAscending)
                {
                    switch (filter.SortColumn)
                    {
                    case "FirstName":
                        orderBy = i => i.OrderBy(x => x.FirstName);
                        break;

                    case "LastName":
                        orderBy = i => i.OrderBy(x => x.LastName);
                        break;

                    case "Age":
                        orderBy = i => i.OrderBy(x => x.Age);
                        break;

                    default:
                        throw new NotSupportedException("Unknow Column Name");
                    }
                }
                else
                {
                    switch (filter.SortColumn)
                    {
                    case "FirstName":
                        orderBy = i => i.OrderByDescending(x => x.FirstName);
                        break;

                    case "LastName":
                        orderBy = i => i.OrderByDescending(x => x.LastName);
                        break;

                    case "Age":
                        orderBy = i => i.OrderByDescending(x => x.Age);
                        break;

                    default:
                        throw new NotSupportedException("Unknow Column Name");
                    }
                }
            }

            return(query.ApplyFilter(where, orderBy));
        }
 public Task <List <PersonDto> > GetPersons(PersonFilter filter)
 {
     throw new NotImplementedException();
 }
        /// <inheritdoc />
        public async Task <MementoResponse <Page <PersonListContract> > > GetAllAsync(PersonFilter personFilter = null)
        {
            var parameters = new Dictionary <string, string>();

            // Build the parameters
            if (personFilter != null)
            {
                // Populate the filter parameters
                if (string.IsNullOrWhiteSpace(personFilter.Name) == false)
                {
                    parameters.Add(nameof(personFilter.Name), personFilter.Name);
                }
                if (string.IsNullOrWhiteSpace(personFilter.Biography) == false)
                {
                    parameters.Add(nameof(personFilter.Biography), personFilter.Biography);
                }
                if (personFilter.BornAfter != null)
                {
                    parameters.Add(nameof(personFilter.BornAfter), personFilter.BornAfter.Value.ToUtcString());
                }
                if (personFilter.BornBefore != null)
                {
                    parameters.Add(nameof(personFilter.BornBefore), personFilter.BornBefore.Value.ToUtcString());
                }

                // Populate the pagination parameters
                parameters.Add(nameof(personFilter.PageNumber), personFilter.PageNumber.ToString());
                parameters.Add(nameof(personFilter.PageSize), personFilter.PageSize.ToString());
                parameters.Add(nameof(personFilter.OrderBy), personFilter.OrderBy.ToString());
                parameters.Add(nameof(personFilter.OrderDirection), personFilter.OrderDirection.ToString());
            }

            // Invoke the API
            var response = await this.HttpService.GetAsync <Page <PersonListContract> >($"{API_URL}", parameters);

            if (!response.Success)
            {
                throw new ApplicationException(string.Join(Environment.NewLine, response.Errors));
            }
            else
            {
                return(response);
            }
        }
Exemple #7
0
 public IEnumerable <Person> GetLatestCalc(PersonFilter personFilter)
 {
     return(_personRepository.GetLatestCalc(personFilter));
 }
Exemple #8
0
        public async Task <ActionResult <MementoResponse <IPage <PersonListContract> > > > GetAsync([FromQuery] PersonFilter filter)
        {
            // Get the persons
            var persons = await this.Repository.GetAllAsync(filter);

            // Build the response
            return(this.BuildGetAllResponse <Person, PersonListContract>(persons));
        }
        private IEnumerable<IssueReplyFeedModel> CreateIssueReplyFeed(IEnumerable<IssueReply> anIssueReplys, User aViewingUser, PersonFilter aPersonFilter)
        {
            List<IssueReplyFeedModel> myFeedModels = new List<IssueReplyFeedModel>();

            foreach (IssueReply myIssueReply in anIssueReplys) {
                IEnumerable<IssueReplyDisposition> myReplyDisposition = myIssueReply.IssueReplyDispositions;

                IssueReplyFeedModel myFeedModel = new IssueReplyFeedModel(myIssueReply.User) {
                    Id = myIssueReply.Id,
                    DateTimeStamp = TimezoneHelper.ConvertToLocalTimeZone(myIssueReply.DateTimeStamp),
                    State = myIssueReply.State,
                    City = myIssueReply.City,
                    IssueReplyComments = myIssueReply.IssueReplyComments,
                    Issue = myIssueReply.Issue,
                    Reply = myIssueReply.Reply,
                    PersonFilter = aPersonFilter,
                    TotalLikes = (from d in myReplyDisposition where d.Disposition == (int)Disposition.Like select d).Count<IssueReplyDisposition>(),
                    TotalDislikes = (from d in myReplyDisposition where d.Disposition == (int)Disposition.Dislike select d).Count<IssueReplyDisposition>(),
                    HasDisposition = ((aViewingUser == null) || (from d in myReplyDisposition where d.UserId == aViewingUser.Id select d).Count<IssueReplyDisposition>() > 0) ? true : false,
                    TotalComments = myIssueReply.IssueReplyComments.Count
                };

                myFeedModels.Add(myFeedModel);
            }

            return myFeedModels;
        }
        private IEnumerable<IssueFeedModel> CreateIssueFeedForAuthority(IEnumerable<Issue> anIssues, UserInformationModel<User> aViewingUser, PersonFilter aPersonFilter)
        {
            List<IssueFeedModel> myFeedModels = new List<IssueFeedModel>();
            foreach (Issue myIssue in anIssues) {
                IEnumerable<IssueDisposition> myIssueDisposition = myIssue.IssueDispositions;

                bool myIsAllowed = PrivacyHelper.IsAllowed(myIssue.User, PrivacyAction.DisplayProfile, aViewingUser);

                IssueFeedModel myFeedModel = new IssueFeedModel(myIssue.User) {
                    Issue = myIssue,
                    PersonFilter = aPersonFilter,
                    IsAnonymous = !myIsAllowed,
                    DateTimeStamp = TimezoneHelper.ConvertToLocalTimeZone(myIssue.DateTimeStamp)
                };

                myFeedModels.Add(myFeedModel);
            }

            return myFeedModels;
        }
        private IEnumerable<IssueFeedModel> CreateIssueFeed(IEnumerable<Issue> anIssues, User aViewingUser, PersonFilter aPersonFilter)
        {
            List<IssueFeedModel> myFeedModels = new List<IssueFeedModel>();

            foreach (Issue myIssue in anIssues) {
                IEnumerable<IssueDisposition> myIssueDisposition = myIssue.IssueDispositions;

                IssueFeedModel myFeedModel = new IssueFeedModel(myIssue.User) {
                    Issue = myIssue,
                    PersonFilter = aPersonFilter,
                    DateTimeStamp = TimezoneHelper.ConvertToLocalTimeZone(myIssue.DateTimeStamp)
                };

                myFeedModels.Add(myFeedModel);
            }

            return myFeedModels;
        }
 public List <PersonDto> Get(PersonFilter filter)
 {
     return(db.Persons.Where(w => String.IsNullOrEmpty(filter.FullName)? true: w.FullName.ToLower().Contains(filter.FullName.ToLower())).ProjectTo <PersonDto>().ToList());
 }
        public override IEnumerable <Person> GetByFilter(IFilter filter)
        {
            PersonFilter f = filter as PersonFilter;

            return(GetByFilter(x => string.IsNullOrEmpty(f.Name) || x.Name.Equals(f.Name)));
        }
Exemple #14
0
        private IEnumerable <Expression <Func <Person, bool> > > CreateWhereClausesFromFilter(PersonFilter filter)
        {
            var clauses = new List <Expression <Func <Person, bool> > >();

            if (filter.NameFilters.Any())
            {
                foreach (StringFilter nameFilter in filter.NameFilters)
                {
                    StringFilter localFilter = nameFilter;
                    if (nameFilter.Operator == Operator.Equals)
                    {
                        clauses.Add(person => person.Name.ToLowerInvariant() == localFilter.Value.ToLowerInvariant());
                    }
                    else if (nameFilter.Operator == Operator.Contains)
                    {
                        clauses.Add(person => person.Name.ToLowerInvariant().Contains(localFilter.Value.ToLowerInvariant()));
                    }
                }
            }
            if (filter.AgeFilters.Any())
            {
                foreach (IntFilter ageFilter in filter.AgeFilters)
                {
                    IntFilter localFilter = ageFilter;
                    if (ageFilter.Operator == Operator.Equals)
                    {
                        clauses.Add(person => person.Age == localFilter.Value);
                    }
                    else if (ageFilter.Operator == Operator.GreaterThan)
                    {
                        clauses.Add(person => person.Age > localFilter.Value);
                    }
                    else if (ageFilter.Operator == Operator.LessThan)
                    {
                        clauses.Add(person => person.Age < localFilter.Value);
                    }
                }
            }
            return(clauses);
        }
 public async Task <List <PersonDto> > GetPersonDtos([FromBody] PersonFilter filter)
 {
     return(await _personService.GetPersons(filter));
 }
 public ActionResult <IEnumerable <Data.Person> > FilterByDynamic([FromQuery] PersonFilter filter)
 {
     return(this.Ok(this._applicationDbContext.Persons.FilterByDynamic(filter)));
 }
        public async Task <PaginatedPlainModel <Person> > GetAll(int startIndex, int pageSize, PersonFilter personFilter = null)
        {
            var filteredPersons = SearchByFilters(personFilter, container.Persons.AsQueryable());
            var persons         = await PaginatedPlainModel <Person> .Paginate(filteredPersons, startIndex, pageSize);

            return(await Task.FromResult(persons).ConfigureAwait(false));
        }
        private IEnumerable<IssueReplyFeedModel> CreateIssueReplyFeedForAuthority(IEnumerable<IssueReply> anIssueReplys, UserInformationModel<User> aViewingUser, PersonFilter aPersonFilter)
        {
            List<IssueReplyFeedModel> myFeedModels = new List<IssueReplyFeedModel>();

            foreach (IssueReply myIssueReply in anIssueReplys) {
                IEnumerable<IssueReplyDisposition> myReplyDisposition = myIssueReply.IssueReplyDispositions;

                bool myIsAllowed = true;
                User myUser = myIssueReply.User;

                IssueReplyFeedModel myFeedModel = new IssueReplyFeedModel(myUser) {
                    IsAnonymous = !myIsAllowed,
                    Id = myIssueReply.Id,
                    DateTimeStamp = TimezoneHelper.ConvertToLocalTimeZone(myIssueReply.DateTimeStamp),
                    State = myIssueReply.State,
                    City = myIssueReply.City,
                    IssueReplyComments = myIssueReply.IssueReplyComments,
                    Issue = myIssueReply.Issue,
                    Reply = myIssueReply.Reply,
                    PersonFilter = aPersonFilter,
                    TotalLikes = (from d in myReplyDisposition where d.Disposition == (int)Disposition.Like select d).Count<IssueReplyDisposition>(),
                    TotalDislikes = (from d in myReplyDisposition where d.Disposition == (int)Disposition.Dislike select d).Count<IssueReplyDisposition>(),
                    HasDisposition = (from d in myReplyDisposition where d.UserId == aViewingUser.Details.Id select d).Count<IssueReplyDisposition>() > 0 ? true : false,
                    TotalComments = myIssueReply.IssueReplyComments.Count
                };

                if (myUser.Id == HAVConstants.PRIVATE_USER_ID) {
                    myFeedModel.DisplayName = myIssueReply.TempFirstName + " " + myIssueReply.TempLastName;
                }

                myFeedModels.Add(myFeedModel);
            }

            return myFeedModels;
        }
Exemple #19
0
 public OmvendtFilter(PersonFilter filterToBeNegated)
 {
     this.FilterToBeNegated = filterToBeNegated;
 }
Exemple #20
0
        public ActionResult Filter(PersonFilter filter)
        {
            var persons = repo.Persons.Get(filter);

            return(PartialView(persons));
        }
    /// <summary>
    /// Build the search request, submit the search and process the result.
    /// This is the handler for the main search using the full set of criteria
    /// </summary>
    private void ProcessProfileSearch()
    {
        Profiles searchReq = ProfileHelper.GetNewProfilesDefinition();

        string lastName = this.HTMLEncode(txtLastName.Text.Trim());
        string firstName = this.HTMLEncode(txtFirstName.Text.Trim());

        Session["ProfileSearchRequestCriteriaList"] = new List<string>();
        Session["ProfileSearchRequestKeywordList"] = new List<string>();

        // Reset current page number
        Session["ProfileSearchResultsPage"] = 0;

        grdSearchResults.DataSource = null;

        // Name
        if (lastName.Length > 0)
        {
            searchReq.QueryDefinition.Name.LastName.Text = lastName.Trim();
            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(lastName);
        }

        if (firstName.Length > 0)
        {
            searchReq.QueryDefinition.Name.FirstName.Text = firstName.Trim();
            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(firstName);
        }

        // Institution Selection
        if (ddlInstitution.SelectedIndex != 0)
        {
            AffiliationInstitutionName affilInstname = new AffiliationInstitutionName();
            affilInstname.Text = ddlInstitution.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].InstitutionName = affilInstname;

            // Set the appropriate message on the right
            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkInstitution.Checked == true ? "All except " + affilInstname.Text : affilInstname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].InstitutionName.Exclude = chkInstitution.Checked;
        }

        // Division Selection
        if (ddlDivision.SelectedIndex != 0)
        {
            AffiliationDivisionName affilDivname = new AffiliationDivisionName();
            affilDivname.Text = ddlDivision.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DivisionName = affilDivname;

            // Set the appropriate message on the right
            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkInstitution.Checked == true ? "All except " + affilDivname.Text : affilDivname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DivisionName.Exclude = chkDivision.Checked;
        }

        // Department Selection
        if (ddlDepartment.SelectedIndex != 0)
        {
            AffiliationDepartmentName affilDeptname = new AffiliationDepartmentName();
            affilDeptname.Text = ddlDepartment.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DepartmentName = affilDeptname;

            // Set the appropriate message on the right
            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkDepartment.Checked == true ? "All except " + affilDeptname.Text : affilDeptname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DepartmentName.Exclude = chkDepartment.Checked;
        }

        // Faculty Selection
        if (ddlFacultyRank.SelectedIndex != 0)
        {

            FacultyRankList ftList = new FacultyRankList();

            searchReq.QueryDefinition.FacultyRankList = new FacultyRankList();
            searchReq.QueryDefinition.FacultyRankList.FacultyRank = new List<string>();

            searchReq.QueryDefinition.FacultyRankList.FacultyRank.Add(ddlFacultyRank.SelectedItem.Value.ToString());

            ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(ddlFacultyRank.SelectedItem.Text);
        }

        // Person Filter Section
        HiddenField hdnSelectedText = ((HiddenField)ctcFirst.FindControl("hdnSelectedText"));
        PersonFilter pf;
        searchReq.QueryDefinition.PersonFilterList = new PersonFilterList();

        if ((hdnSelectedText.Value.Length > 0) && (hdnSelectedText.Value != "--Select--"))
        {
            string[] pfArray = hdnSelectedText.Value.Split(',');

            for (int i = 0; i < pfArray.Length; i++)
            {
                pf = new PersonFilter();
                pf.Text = pfArray[i];

                searchReq.QueryDefinition.PersonFilterList.Add(pf);

                ((List<string>)Session["ProfileSearchRequestCriteriaList"]).Add(pfArray[i]);
            }
        }

        // Keywords
        if (txtKeyword.Text.Trim().Length > 0)
        {
            string keywordString;

            if (chkKeyword.Checked == true)
            {
                keywordString = this.HTMLEncode(txtKeyword.Text.Trim().Replace("\"", ""));

                searchReq.QueryDefinition.Keywords.KeywordString.Text = keywordString;
                searchReq.QueryDefinition.Keywords.KeywordString.MatchType = KeywordMatchType.exact;
                ((List<string>)Session["ProfileSearchRequestKeywordList"]).Add(keywordString);
            }
            else
            {
                keywordString = this.HTMLEncode(txtKeyword.Text.Trim());

                searchReq.QueryDefinition.Keywords.KeywordString.Text = keywordString;

                ((List<string>)Session["ProfileSearchRequestKeywordList"]).Add(keywordString);
            }
        }

        searchReq.Version = 2;

        // Save the search request into a session object so that the
        // object data source can use it during the Select event

        Session["ProfileSearchRequest"] = searchReq;

        Session["MeshSearch"] = 0;
        Session["SearchPageIndex"] = 0;
        Session["WasSearchRun"] = "Y";

        // Get results bound to grid
        BindSearchResults(0);

        SetBackPageURL();
    }
Exemple #22
0
        static void Main(string[] args)
        {
            //Make a new instance of the User Interface class
            //Just commented this to use the static one instead
            UserInterface ui = new UserInterface();

            //Let's make an array to hold a bunch of instances of the Employee class
            IEmployee[] employees = new IEmployee[10];

            //Let's add some employees to our array
            employees[0] = new SalaryEmployee("David", "Barnes", 835.00m);
            employees[1] = new SalaryEmployee("James", "Kirk", 453.00m);
            employees[2] = new HourlyEmployee("Jean-Luc", "Picard", 9.00m, 40.0m);
            employees[3] = new SalaryEmployee("Benjamin", "Sisko", 587.00m);
            employees[4] = new HourlyEmployee("Kathryn", "Janeway", 9.40m, 20.0m);
            employees[5] = new SalaryEmployee("Johnathan", "Archer", 135.00m);

            //Get some input from the user
            int choice = ui.GetUserInput();

            //While the choice they selected is not 2, continue to do work
            while (choice != 3)
            {
                //See if the input they sent is equal to 1.
                if (choice == 1)
                {
                    //Create a string that can be concated to
                    string outputString = "";

                    //Print out the employees in the array
                    foreach (Employee employee in employees)
                    {
                        if (employee != null)
                        {
                            //Concat to the outputString
                            outputString += employee.ToString() +
                                            Environment.NewLine;
                        }
                    }

                    //Use the UI class to print out the string
                    ui.Output(outputString);
                }

                //See if the input they sent is equal to 1.
                if (choice == 2)
                {
                    PersonFilter filter            = new PersonFilter();
                    IPerson[]    filteredEmployees = filter.FilterByFirstName(employees, "David");

                    // Create a string that can be concated to
                    string outputString = "";

                    // Print out the employees in the array
                    foreach (IEmployee employee in filteredEmployees)
                    {
                        if (employee != null)
                        {
                            outputString += employee.ToString() + Environment.NewLine;
                        }
                    }
                    ui.Output(outputString);
                }

                //re-prompt the user for input
                choice = ui.GetUserInput();
            }
        }
 public ActionResult FilterIssueByPersonFilter(PersonFilter filterValue, int id)
 {
     return FilterIssue(PERSON_FILTER, filterValue.ToString(), id);
 }
Exemple #24
0
        public async Task <IEnumerable <PersonResponse> > ListPersons(PersonFilter filter)
        {
            var result = await this.PersonRepository.List(filter);

            return(Mapper.Map <List <PersonResponse> >(result));
        }
        public async Task <PaginatedPlainModel <Person> > GetAll(int startIndex, int pageSize, PersonFilter personFilter)
        {
            var filteredPersons = SearchByFilters(personFilter, context.Persons.Include(p => p.ApplicationUser).AsQueryable());
            var persons         = await PaginatedPlainModel <Person> .Paginate(filteredPersons, startIndex, pageSize);

            return(persons);
        }
Exemple #26
0
        public static IQueryable <PersonEntity> FilterEntities(this IQueryable <PersonEntity> source, PersonFilter filters)
        {
            if (filters.FirstName != null)
            {
                source = source.Where(p => p.FirstName.ToLower().Contains(filters.FirstName));
            }

            if (filters.LastName != null)
            {
                source = source.Where(p => p.LastName.ToLower().Contains(filters.LastName));
            }

            if (filters.PersonalNumber != null)
            {
                source = source.Where(p => p.PersonalNumber.Contains(filters.PersonalNumber));
            }

            if (filters.DateOfBirth != null)
            {
                source = source.Where(p => p.DateOfBirth == filters.DateOfBirth);
            }

            if (filters.City != null)
            {
                source = source.Where(p => p.City.Name.ToLower().Contains(filters.City));
            }

            if (filters.Gender != null)
            {
                source = source.Where(p => p.Gender == filters.Gender);
            }

            if (filters.PhoneNumber != null)
            {
                source = source.Where(p => p.PhoneNumbers.Any(ph => ph.Number.Contains(filters.PhoneNumber)));
            }

            if (filters.PhoneNumberType != null)
            {
                source = source.Where(p => p.PhoneNumbers.Any(ph => ph.Type == filters.PhoneNumberType));
            }

            return(source);
        }
Exemple #27
0
        public async Task <Result> LookupFilter(PersonFilter filter)
        {
            var items = await Repository.FindAsync(x => x.Name.Contains(filter.Name));

            return(await Return(items.ToList().Select(ConvertToLookupResponse)));
        }
Exemple #28
0
        public async Task <ActionResult <ListResult <PersonDto, PersonFilter> > > GetAll(PersonFilter filter, int page = 1)
        {
            var result = await _service.GetAllAsync(filter, new Paging(page, _settings.PerPage));

            return(Ok(result));
        }
        public static string PersonFilterButton(PersonFilter aFilter, PersonFilter aSelectedFilter, string aDisplayName, string aNonSelectedCssClass, string aSelectedCssClass)
        {
            var linkTag = new TagBuilder("a");
            linkTag.InnerHtml = aDisplayName;
            linkTag.MergeAttribute("href", "/Profile/FilterFeed?filterValue=" + aFilter);
            if (aSelectedFilter == aFilter) {
                linkTag.MergeAttribute("class", aSelectedCssClass);
            } else {
                linkTag.MergeAttribute("class", aNonSelectedCssClass);
            }

            return linkTag.ToString();
        }
Exemple #30
0
 public SuperFilter(PersonFilter pf1, PersonFilter pf2)
 {
     this.pf1 = pf1;
     this.pf2 = pf2;
 }
    /// <summary>
    /// Build the search request, submit the search and process the result.
    /// This is the handler for the main search using the full set of criteria
    /// </summary>
    private void ProcessProfileSearch()
    {
        Profiles searchReq = ProfileHelper.GetNewProfilesDefinition();

        string lastName  = this.HTMLEncode(txtLastName.Text.Trim());
        string firstName = this.HTMLEncode(txtFirstName.Text.Trim());

        Session["ProfileSearchRequestCriteriaList"] = new List <string>();
        Session["ProfileSearchRequestKeywordList"]  = new List <string>();

        // Reset current page number
        Session["ProfileSearchResultsPage"] = 0;

        grdSearchResults.DataSource = null;

        // Name
        if (lastName.Length > 0)
        {
            searchReq.QueryDefinition.Name.LastName.Text = lastName.Trim();
            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(lastName);
        }

        if (firstName.Length > 0)
        {
            searchReq.QueryDefinition.Name.FirstName.Text = firstName.Trim();
            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(firstName);
        }

        // Institution Selection
        if (ddlInstitution.SelectedIndex != 0)
        {
            AffiliationInstitutionName affilInstname = new AffiliationInstitutionName();
            affilInstname.Text = ddlInstitution.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].InstitutionName = affilInstname;

            // Set the appropriate message on the right
            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkInstitution.Checked == true ? "All except " + affilInstname.Text : affilInstname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].InstitutionName.Exclude = chkInstitution.Checked;
        }

        // Division Selection
        if (ddlDivision.SelectedIndex != 0)
        {
            AffiliationDivisionName affilDivname = new AffiliationDivisionName();
            affilDivname.Text = ddlDivision.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DivisionName = affilDivname;

            // Set the appropriate message on the right
            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkInstitution.Checked == true ? "All except " + affilDivname.Text : affilDivname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DivisionName.Exclude = chkDivision.Checked;
        }


        // Department Selection
        if (ddlDepartment.SelectedIndex != 0)
        {
            AffiliationDepartmentName affilDeptname = new AffiliationDepartmentName();
            affilDeptname.Text = ddlDepartment.SelectedItem.Text;
            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DepartmentName = affilDeptname;

            // Set the appropriate message on the right
            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(chkDepartment.Checked == true ? "All except " + affilDeptname.Text : affilDeptname.Text);

            searchReq.QueryDefinition.AffiliationList.Affiliation[0].DepartmentName.Exclude = chkDepartment.Checked;
        }

        // Faculty Selection
        if (ddlFacultyRank.SelectedIndex != 0)
        {
            FacultyRankList ftList = new FacultyRankList();

            searchReq.QueryDefinition.FacultyRankList             = new FacultyRankList();
            searchReq.QueryDefinition.FacultyRankList.FacultyRank = new List <string>();

            searchReq.QueryDefinition.FacultyRankList.FacultyRank.Add(ddlFacultyRank.SelectedItem.Value.ToString());

            ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(ddlFacultyRank.SelectedItem.Text);
        }

        // Person Filter Section
        HiddenField  hdnSelectedText = ((HiddenField)ctcFirst.FindControl("hdnSelectedText"));
        PersonFilter pf;

        searchReq.QueryDefinition.PersonFilterList = new PersonFilterList();

        if ((hdnSelectedText.Value.Length > 0) && (hdnSelectedText.Value != "--Select--"))
        {
            string[] pfArray = hdnSelectedText.Value.Split(',');

            for (int i = 0; i < pfArray.Length; i++)
            {
                pf      = new PersonFilter();
                pf.Text = pfArray[i];

                searchReq.QueryDefinition.PersonFilterList.Add(pf);

                ((List <string>)Session["ProfileSearchRequestCriteriaList"]).Add(pfArray[i]);
            }
        }

        // Keywords
        if (txtKeyword.Text.Trim().Length > 0)
        {
            string keywordString;

            if (chkKeyword.Checked == true)
            {
                keywordString = this.HTMLEncode(txtKeyword.Text.Trim().Replace("\"", ""));

                searchReq.QueryDefinition.Keywords.KeywordString.Text      = keywordString;
                searchReq.QueryDefinition.Keywords.KeywordString.MatchType = KeywordMatchType.exact;
                ((List <string>)Session["ProfileSearchRequestKeywordList"]).Add(keywordString);
            }
            else
            {
                keywordString = this.HTMLEncode(txtKeyword.Text.Trim());

                searchReq.QueryDefinition.Keywords.KeywordString.Text = keywordString;


                ((List <string>)Session["ProfileSearchRequestKeywordList"]).Add(keywordString);
            }
        }

        searchReq.Version = 2;

        // Save the search request into a session object so that the
        // object data source can use it during the Select event


        Session["ProfileSearchRequest"] = searchReq;

        Session["MeshSearch"]      = 0;
        Session["SearchPageIndex"] = 0;
        Session["WasSearchRun"]    = "Y";

        // Get results bound to grid
        BindSearchResults(0);

        SetBackPageURL();
    }
        public async Task <IEnumerable <Person> > List(PersonFilter filter)
        {
            var result = await this.PersonCollection.FindAsync <Person>(p => true);

            return(result.ToList().Skip(int.Parse(filter.Offset)).Take(int.Parse(filter.Limit)));
        }