Ejemplo n.º 1
0
        public bool AddDiscBand(SellInfo sellInfo)
        {
            //Band band = new Band();
            //if (context.Bands.Any(p => p.Name == sellInfo.BandName))
            //{
            //    band = context.Bands.FirstOrDefault(p => p.Name == sellInfo.BandName);
            //}
            //else band = new Band { Name = sellInfo.BandName, Year = sellInfo.BandDate };
            try
            {
                AddDisc(sellInfo, AddBand(sellInfo.BandName, sellInfo.BandDate));
            }
            catch (Exception)
            {
                return(false);
            }
            //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();

            return(true);
        }
Ejemplo n.º 2
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();
     }
 }