Beispiel #1
0
        private void buttonBestSellersYear_Click(object sender, EventArgs e)
        {
            using (MyDbContext context = new MyDbContext())
            {
                try
                {
                    var BestSellersMonth = context.Sellings.AsEnumerable()
                                           .Where(r => r.DateSell.Year == DateTime.Now.Year)
                                           .GroupBy(r => r.IdDisk)
                                           .OrderByDescending(g => g.Sum(r => r.Quantity))
                                           .Select(g => g.First().IdDisk).ToList();
                    //.Take(3).ToList();

                    List <Disk> disks = new List <Disk>();
                    foreach (var item in context.Disks.ToList())
                    {
                        foreach (var item2 in BestSellersMonth)
                        {
                            if (item.IdDisk == item2)
                            {
                                disks.Add(item);
                            }
                        }
                    }
                    ResultsDiscs f9 = new ResultsDiscs(disks);
                    f9.ShowDialog();
                }
                catch (Exception ex) { }
            }
        }
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (radioButtonTitle.Checked)
            {
                using (MyDbContext context = new MyDbContext())
                {
                    try
                    {
                        var          res = context.Disks.Where(x => x.Title == textBoxTitle.Text).ToList();
                        ResultsDiscs f9  = new ResultsDiscs(res);
                        f9.ShowDialog();
                    }
                    catch (Exception x) { }
                }
            }
            else
            if (radioButtonCollective.Checked)
            {
                using (MyDbContext context = new MyDbContext())
                {
                    try
                    {
                        var          res = context.Disks.Where(x => x.Collective.Name == textBoxCollective.Text).ToList();
                        ResultsDiscs f9  = new ResultsDiscs(res);
                        f9.ShowDialog();
                    }
                    catch (Exception x) { }
                }
            }
            else
            if (radioButtonGenre.Checked)
            {
                using (MyDbContext context = new MyDbContext())
                {
                    try
                    {
                        var         g      = context.Genres.Where(z => z.Title == textBoxGenre.Text).FirstOrDefault();
                        var         res    = context.Genres.Select(x => x.Disks).ToList();
                        List <Disk> result = new List <Disk>();
                        foreach (var item in res)
                        {
                            foreach (var item2 in item)
                            {
                                if (item2.Genres.ToList().Contains(g) == true)
                                {
                                    result.Add(item2);
                                }
                            }
                        }

                        ResultsDiscs f9 = new ResultsDiscs(result);
                        f9.ShowDialog();
                    }
                    catch (Exception x) { }
                }
            }
        }
Beispiel #3
0
 private void buttonLatestNewDiscs_Click(object sender, EventArgs e)
 {
     using (MyDbContext context = new MyDbContext())
     {
         var res = context.Disks.Where(x => x.DtPublish.Month == DateTime.Now.Month).ToList();
         try
         {
             ResultsDiscs f9 = new ResultsDiscs(res);
             f9.ShowDialog();
         }
         catch (Exception ex) { }
     }
 }
Beispiel #4
0
        private void buttonMostPopularGenreMonth_Click(object sender, EventArgs e)
        {
            using (MyDbContext context = new MyDbContext())
            {
                try
                {
                    var PopularGenreMonth = context.Sellings.AsEnumerable()
                                            .Where(r => r.DateSell.Month == DateTime.Now.Month)
                                            .GroupBy(r => r.IdDisk)
                                            .OrderByDescending(g => g.Sum(r => r.Quantity))
                                            .Select(g => g.First().IdDisk).ToList();

                    List <Genre> genre1 = new List <Genre>();
                    foreach (var item in PopularGenreMonth)
                    {
                        foreach (var item2 in context.Disks.ToList())
                        {
                            if (item2.IdDisk == item)
                            {
                                foreach (var item3 in item2.Genres)
                                {
                                    Genre g = context.Genres.Where(x => x.IdGenre == item3.IdGenre).FirstOrDefault();
                                    genre1.Add(g);
                                }
                            }
                        }
                    }
                    var          res   = genre1.GroupBy(x => x.IdGenre);
                    List <Genre> coll2 = new List <Genre>();
                    foreach (var key in res)
                    {
                        foreach (var item in key)
                        {
                            coll2.Add(item);
                            break;
                        }
                    }
                    ResultsDiscs f9 = new ResultsDiscs(coll2);
                    f9.ShowDialog();
                }
                catch (Exception ex) { }
            }
        }