public void AddProductToOrder(string orderId, string productId)
        {
            OrderProduct orderProduct = new OrderProduct {
                OrderId = orderId, ProductId = productId
            };

            context.OrderProducts.Add(orderProduct);
            context.SaveChanges();
        }
        public void CreateOrder(string userId)
        {
            var order = new Order()
            {
                CashierId = userId, IssuedOn = DateTime.Now, Status = OrderStatus.Active
            };

            dbContext.Orders.Add(order);
            dbContext.SaveChanges();
        }
        public void CreateOrder(string cashierId)
        {
            var cashier = db.Users.SingleOrDefault(u => u.Id == cashierId);
            var order   = new Order
            {
                CashierId = cashierId,
                Cashier   = cashier
            };

            db.Orders.Add(order);

            db.SaveChanges();
        }
Example #4
0
        public void AddProductToOrder(string cashierId, string productName)
        {
            var order = GetOrderFromDbByCashierId(cashierId);

            var product = db.Products.SingleOrDefault(x => x.Name == productName);

            if (order != null && product != null)
            {
                order.Products.Add(product);
                Console.WriteLine(order.Products.Count);
                db.SaveChanges();
            }
        }
Example #5
0
        public string CreateOrder(string userId)
        {
            var order = new Order
            {
                CashierId = userId,
                Status    = OrderStatus.Active
            };

            context.Orders.Add(order);
            context.SaveChanges();

            return(order.Id);
        }
 public string CreateUser(User user)
 {
     user.Password = HashPassword(user.Password);
     context.Users.Add(user);
     context.SaveChanges();
     return(user.Id);
 }
Example #7
0
        public string RegisterUser(User user)
        {
            user.Password = HashPassword(user.Password);
            user          = db.Users.Add(user).Entity;
            db.SaveChanges();
            orderService.CreateOrder(user.Id);


            return(user.Id);
        }
        public void Create(string name, decimal price)
        {
            var product = new Product
            {
                Name  = name,
                Price = price
            };

            db.Products.Add(product);

            db.SaveChanges();
        }
Example #9
0
        public string CreateProduct(string name, decimal price)
        {
            if (context.Products.Any(p => p.Name == name && p.Price == price))
            {
                return(null);
            }

            var product = new Product
            {
                Name  = name,
                Price = price
            };

            context.Products.Add(product);
            context.SaveChanges();

            return(product.Id);
        }
Example #10
0
        public string CreateUser(string username, string password, string email)
        {
            if (context.Users.Any(u => u.Username == username))
            {
                return(null);
            }

            var hashPass = HashPassword(password);

            var user = new User
            {
                Username = username,
                Password = hashPass,
                Email    = email
            };

            context.Users.Add(user);
            context.SaveChanges();

            return(user.Id);
        }
Example #11
0
 public Product Create(Product product)
 {
     context.Products.Add(product);
     context.SaveChanges();
     return(product);
 }
 public void CreateProduct(Product product)
 {
     dbContext.Products.Add(product);
     dbContext.SaveChanges();
 }