Esempio n. 1
0
        private void Seed(StudioContext context)
        {
            var categories = new[]
            {
                new Genres {
                    Name = "AAAA"
                },
                new Genres {
                    Name = "BBBB"
                },
            };

            context.Genres.AddRange(categories);
            context.SaveChanges();
        }
        /**
         * CUD
         **/

        public RedirectToRouteResult AddDbTables(Product p, Customer c, Price pr)
        {
            if (!db.Customers.Any(s => s.Email == c.Email || s.PhoneNumber == c.PhoneNumber))
            {
                db.Customers.Add(c);
                db.SaveChanges();
            }

            p.CustomerId = db.Customers.ToList().Find(s => s.Email == c.Email || s.PhoneNumber == c.PhoneNumber).CustomerId;


            db.Products.Add(p);
            db.Prices.Add(pr);

            db.SaveChanges();

            ICollection <Material> m1 = db.Materials.Where(s => s.ProductId == null).ToList();

            foreach (Material m in m1)
            {
                m.ProductId = db.Products.ToList().LastOrDefault().ProductId;
            }
            return(SetBdEd(db.Products.ToList().LastOrDefault().ProductId));
        }
Esempio n. 3
0
 /// <summary>
 /// Método Salvar
 /// </summary>
 public string Salvar()
 {
     return(_context.SaveChanges().ToString());
 }