Exemplo n.º 1
0
        //static void Main(string[] args)
        //{
        //    //Console.WriteLine(GetName());
        //}

        public void CreateNewUser(string firstName, string lastName, string email, string password)
        {
            using (var db = new LeoBayContext())
            {
                string encryptedPassword = _encryption.Encrypt(password);
                db.Add(new User {
                    FirstName = firstName, LastName = lastName, Email = email, Password = encryptedPassword
                });
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        //Checkout

        public void AddToCart()
        {
            using (var db = new LeoBayContext())
            {
                CurrentUser.Id = 1;
                db.Add(new Order {
                    ProductId = 1, BuyerId = CurrentUser.Id, Date = DateTime.Now
                });
                db.SaveChanges();
                CurrentUser.Id = 0;
            }
        }
Exemplo n.º 3
0
 public void AddToCart(int productId)
 {
     using (var db = new LeoBayContext())
     {
         var user  = db.Users.Where(u => u.UserId == CurrentUser.Id).FirstOrDefault();
         var order = db.Orders;
         db.Add(new Order {
             ProductId = productId, BuyerId = CurrentUser.Id, Date = DateTime.Now
         });
         db.SaveChanges();
     }
 }