示例#1
0
        public async Task <JobsResult> SearchAsync(string searchText, CountryGroup countryGroup, bool?remoteOnly, int page = 1)
        {
            var jobs = await MockJobsAsync(1);

            jobs.AddRange(await MockJobsAsync(2));
            jobs.AddRange(await MockJobsAsync(3));

            List <Job> list = null;
            await Task.Run(() =>
            {
                list = jobs.Where(j =>
                {
                    var matchSearch = j.Title.ToUpper().Contains(searchText.ToUpper()) ||
                                      j.Description.ToUpper().Contains(searchText.ToUpper()) ||
                                      j.Skills.Where(s => s.Contains(searchText)).Any();

                    var remoteMatch = (remoteOnly == null) || (remoteOnly.Value == false) || (j.Remote == remoteOnly.Value);

                    var countryMatch = (countryGroup == null) || (countryGroup.All(c => c.Selected == false)) || (countryGroup.Where(c => c.Selected == true && c.Name.ToUpper().Equals(j.Country.ToUpper())).Any());

                    return(matchSearch && remoteMatch && countryMatch);
                })
                       .ToList();
            });

            return(new JobsResult
            {
                Total_Pages = 2,
                Total_Results = list.Count(),
                Results = list
            });
        }
    private static Boolean KawigiEdit_RunTest(int testNum, int[] p0, Boolean hasAnswer, int p1)
    {
        Console.Write("Test " + testNum + ": [" + "{");
        for (int i = 0; p0.Length > i; ++i)
        {
            if (i > 0)
            {
                Console.Write(",");
            }
            Console.Write(p0[i]);
        }
        Console.Write("}");
        Console.WriteLine("]");
        CountryGroup obj;
        int          answer;

        obj = new CountryGroup();
        DateTime startTime = DateTime.Now;

        answer = obj.solve(p0);
        DateTime endTime = DateTime.Now;
        Boolean  res;

        res = true;
        Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
        if (hasAnswer)
        {
            Console.WriteLine("Desired answer:");
            Console.WriteLine("\t" + p1);
        }
        Console.WriteLine("Your answer:");
        Console.WriteLine("\t" + answer);
        if (hasAnswer)
        {
            res = answer == p1;
        }
        if (!res)
        {
            Console.WriteLine("DOESN'T MATCH!!!!");
        }
        else if ((endTime - startTime).TotalSeconds >= 2)
        {
            Console.WriteLine("FAIL the timeout");
            res = false;
        }
        else if (hasAnswer)
        {
            Console.WriteLine("Match :-)");
        }
        else
        {
            Console.WriteLine("OK, but is it right?");
        }
        Console.WriteLine("");
        return(res);
    }
        private void frmGroupBy_Load(object sender, EventArgs e)
        {
            NorthwindEntities dc = new NorthwindEntities();
            var query            = from c in dc.Customers
                                   group c by c.Country into CountryGroup
                                   orderby CountryGroup.Count() descending
                                   select new
            {
                Country = CountryGroup.Key,
                Count   = CountryGroup.Count()
            };

            dataGridView1.DataSource = query.ToList();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'northwindDataSet.Customers' 資料表。您可以視需要進行移動或移除。
            this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
            NorthwindEntities dc = new NorthwindEntities();
            var query            = (from c in dc.Customers
                                    group c by c.Country into CountryGroup
                                    select new
            {
                家 = CountryGroup.Key,
                人數 = CountryGroup.Count()
            }).OrderByDescending(group => group.人數);

            this.dataGridView1.DataSource = query.ToArray();
        }
示例#5
0
 private void UpdateListContent()
 {
     _expandedGroups = new ObservableRangeCollection <CountryGroup>();
     foreach (CountryGroup group in _allGroups)
     {
         CountryGroup newGroup = new CountryGroup(group.Title, group.Expanded);
         if (group.Expanded)
         {
             foreach (Country country in group)
             {
                 newGroup.Add(country);
             }
         }
         _expandedGroups.Add(newGroup);
     }
     Groups = _expandedGroups;
     OnPropertyChanged("Groups");
 }
示例#6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'northwindDataSet.Customers' 資料表。您可以視需要進行移動或移除。
            this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
            // TODO: 這行程式碼會將資料載入 'northwindDataSet.Customers' 資料表。您可以視需要進行移動或移除。
            this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
            //select Country, Count(*) from Customers group by Country
            northwindEntities dc = new northwindEntities();
            //var query = (from c in dc.Customers
            //             group c by c.Country into CountryGroup
            //             select new
            //             {
            //                 國家 = CountryGroup.Key,
            //                 人數 = CountryGroup.Count()
            //             }).OrderByDescending(group => group.人數);
            var query = dc.Customers.GroupBy(c => c.Country).Select(CountryGroup => new
            {
                家  = CountryGroup.Key,
                人數 = CountryGroup.Count()
            }).OrderByDescending(g => g.人數);

            dgvGroup.DataSource = query.ToList();
        }
 public CountryGroupAttribute(CountryGroup group_)
 {
   CountryGroup = group_;
 }