Ejemplo n.º 1
0
        public List <GroupInfo> TotalAmountSellGroup(string GroupName)
        {
            using (DiscContext context = new DiscContext())
            {
                string se = context.Bands.FirstOrDefault(b => b.Name == GroupName).Name;
                int    c  = context.Bands.Include("CDs").FirstOrDefault(b => b.Name == GroupName).CDs.Count;

                Console.WriteLine();
                for (int i = 0; i < context.Bands.FirstOrDefault(b => b.Name == GroupName).CDs.Count; i++)
                {
                    groups.Add(new GroupInfo
                    {
                        Name         = context.Bands.Include("CDs").Include("CDs.Format").Include("CDs.Selling").Include("CDs.Selling.Seller").FirstOrDefault(b => b.Name == GroupName).CDs.ToList()[i].Name,
                        Cd_Date      = context.Bands.Include("CDs").Include("CDs.Format").Include("CDs.Selling").Include("CDs.Selling.Seller").FirstOrDefault(b => b.Name == GroupName).CDs.ToList()[i].Cd_Date,
                        Format       = context.Bands.Include("CDs").Include("CDs.Format").Include("CDs.Selling").Include("CDs.Selling.Seller").FirstOrDefault(b => b.Name == GroupName).CDs.ToList()[i].Format.Name,
                        SellingCount = context.Bands.Include("CDs").Include("CDs.Format").Include("CDs.Selling").Include("CDs.Selling.Seller").FirstOrDefault(b => b.Name == GroupName).CDs.ToList()[i].Selling.Count()
                    });
                }



                Console.WriteLine();
                return(groups);
            }
        }
Ejemplo n.º 2
0
        public List <SellInfo> AllSellInfo()

        {
            List <SellInfo> sell = new List <SellInfo>();

            using (DiscContext context = new DiscContext())
            {
                int c = context.Sellings.Count();
                for (int i = 0; i < c; i++)
                {
                    sell.Add(
                        new SellInfo
                    {
                        SellerName = context.Sellings.Include("CD").Include("Seller").ToList()[i].Seller.Name,
                        BandName   = context.Sellings.Include("CD").Include("Seller").Include("CD.Band").Include("CD.Format").ToList()[i].CD.Band.Name,
                        CDName     = context.Sellings.Include("CD").Include("Seller").Include("CD.Band").Include("CD.Format").ToList()[i].CD.Name,
                        Cd_Date    = context.Sellings.Include("CD").Include("Seller").Include("CD.Band").Include("CD.Format").ToList()[i].CD.Cd_Date,
                        FormatName = context.Sellings.Include("CD").Include("Seller").Include("CD.Band").Include("CD.Format").ToList()[i].CD.Format.Name,
                        DateTime   = new DateTime(2018, 9, 5 + i)
                    });
                }
            }

            return(sell);
        }
Ejemplo n.º 3
0
 public void AddSell(string discName, string cashier)
 {
     using (DiscContext context = new DiscContext())
     {
         context.Sellings.Add(new Selling {
             CD     = context.CDs.FirstOrDefault(s => s.Name == discName),
             Seller = context.Sellers.FirstOrDefault(s => s.Name == cashier)
         });
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        public string MostPopularGroup()
        {
            using (DiscContext context = new DiscContext())
            {
                int    max = context.Bands.Include("CDs").Include("CDs.Format").Include("CDs.Selling").Include("CDs.Selling.Seller").Max(p => p.CDs.Max(r => r.Selling.Count()));
                string s   = context.CDs.FirstOrDefault(p => p.Selling.Count == 2).Name;

                string str = context.Bands.FirstOrDefault(t => t.CDs.Select(i => i.Name).FirstOrDefault() == s).Name;
                //string fg = groups.FirstOrDefault(p => p.SellingCount == 2).Name;

                return(str);
            }
        }
Ejemplo n.º 5
0
 private void AddDisc(SellInfo sellInfo, Band band)
 {
     using (DiscContext context = new DiscContext())
     {
         context.CDs.Add(
             new CD
         {
             Name    = sellInfo.CDName,
             Cd_Date = sellInfo.Cd_Date,
             Format  = context.Formats.FirstOrDefault(f => f.Name == sellInfo.FormatName),
             Band    = band
         });
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            using (DiscContext context = new DiscContext())
            {
                try
                {
                    Database.SetInitializer(new DiscInitializer());

                    context.Database.Initialize(true);


                    Console.WriteLine("Database OK!");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    ServiceHost serviceHost = new ServiceHost(typeof(DiscInfo));
                    DiscInfo    disc        = new DiscInfo();
                    // disc.AllSellInfo();
                    //disc.TotalAmountSellGroup("Наутилус");
                    //disc.MostPopularGroup();
                    disc.ShowAllDiscs();

                    serviceHost.Open();

                    Console.WriteLine("Up and running!");
                    //  ZodiacFind zodiacFind = new ZodiacFind();
                    //zodiacFind.FindWestHoroscope(new DateTime(2018,6,2));

                    Console.ReadLine();

                    serviceHost.Close();

                    Console.WriteLine("Service closed!");
                }


                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Ejemplo n.º 7
0
        public List <Disc> ShowAllDiscs()
        {
            List <Disc> discs = new List <Disc>();



            using (DiscContext context = new DiscContext())
            {
                for (int i = 0; i < context.CDs.Count(); i++)
                {
                    discs.Add(new Disc {
                        Name       = context.CDs.Include("Format").Include("Band").ToList()[i].Name,
                        BandName   = context.CDs.Include("Format").Include("Band").ToList()[i].Band.Name,
                        FormatName = context.CDs.Include("Format").Include("Band").ToList()[i].Format.Name,
                        Cd_Date    = context.CDs.Include("Format").Include("Band").ToList()[i].Cd_Date
                    });
                }
                return(discs);
            }
        }
Ejemplo n.º 8
0
        private Band AddBand(string bandName, int bandDate)
        {
            using (DiscContext context = new DiscContext())
            {
                Band band = new Band();
                if (context.Bands.Any(p => p.Name == bandName))
                {
                    band = context.Bands.FirstOrDefault(p => p.Name == bandName);
                }
                else
                {
                    band = new Band {
                        Name = bandName, Year = bandDate
                    };
                    context.Bands.Add(band);
                }

                return(context.Bands.AsEnumerable().Last());
            }
        }