Example #1
0
 public string AddProduct(string name, int price, int qty)
 {
     pdc.Products.Add(new Product()
     {
         Name = name, Price = price, Qty = qty
     });
     pdc.SaveChanges();
     return("New product was succesfully created");
 }
Example #2
0
        public int AddOrder(int customerId, int orderSum)
        {
            var returnValue = ctx.Orders.Add(new Order
            {
                Date        = DateTime.Now,
                OurCustomer = customerId,
                OrderSum    = orderSum
            });

            ctx.SaveChanges();
            return(returnValue.Entity.Id);
        }
Example #3
0
        public int AddCustomer(string firstName, string lastName, string address, string city, string email, string phoneNr, int zipcode)
        {
            var createdCustomer = pdc.Customers.Add(new Customer
            {
                Firstname = firstName,
                Lastname  = lastName,
                Address   = address,
                City      = city,
                Email     = email,
                PhoneNr   = phoneNr,
                Zipcode   = zipcode
            });

            pdc.SaveChanges();
            return(createdCustomer.Entity.CustomerId);
        }
Example #4
0
        private static void CreateDb()
        {
            using (var context = new PropellerDataContext())

            {
                context.Database.EnsureCreated();
                context.SaveChanges();
            }
        }