Пример #1
0
 public Product GetProductByIdFromDataStore(string id)
 {
     using (HalloweenEntities data = new HalloweenEntities())
     {  //Get a product from Products of data where ProductID is matched with id parameter
         return(data.Products.Where <Product>(x => x.ProductID == id).FirstOrDefault());
     }
 }
      }//close GetAllProducts()


      public Product GetProductByIdFromDataStore(string id) {
         using (HalloweenEntities data = new HalloweenEntities()) {
            //Get a product from Products of data where ProductID is matched with id parameter
            return data.Products.Where(p => p.ProductID == id).FirstOrDefault();
            //return data.Products.FirstOrDefault();
         }//end using
      }//close GetProductByIdFromDataStore(...)
Пример #3
0
 //Implement GetAllProductsFromDataStore
 public List<Product> GetAllProductsFromDataStore() {
    using (HalloweenEntities data = new HalloweenEntities()) {
           //get all the products from the Collection Products order by name using HalloweenEntities
           return data.Products.OrderBy(p => p.Name).ToList();
           // return data.Products.OrderBy(p => p.Name).ToList();
       }//end using
 }//close GetAllProductsFromDataStore()
Пример #4
0
 //Implement GetAllProductsFromDataStore
 public List <Product> GetAllProductsFromDataStore()
 {
     using (HalloweenEntities data = new HalloweenEntities())
     {  //get all the products from the Collection Products order by name using HalloweenEntities
         return(data.Products.ToList());
     }
 }
 public Product GetProductByIdFromDataStore(string id)
 {
     using (HalloweenEntities data = new HalloweenEntities())
     {  //Get a product from Products of data where ProductID is matched with id parameter
         return(data.Set <Product>().Find(id));
     }
 }
 //Implement GetAllProductsFromDataStore
 public List <Product> GetAllProductsFromDataStore()      ///////GetAllProducts() method
 {
     using (HalloweenEntities data = new HalloweenEntities())
     {  //get all the products from the Collection Products order by name using HalloweenEntities
         //_________________________________________
         return(data.Products.OrderBy(product => product.Name).ToList());
     }
 }
Пример #7
0
        public void UpdateSoldProductQuantity()
        {
            HalloweenEntities data = new HalloweenEntities();

            foreach (var item in cart)
            {
                data.Products.Find(item.ProductID).OnHand -= item.Quantity;
                data.SaveChanges();
            }
            data.SaveChanges();
        }
        public ActionResult Registration(User user)
        {
            //Validation
            if (ModelState.IsValid)
            {
                using (HalloweenEntities data = new HalloweenEntities())
                {
                    data.User.Add(user);
                    data.SaveChanges();
                }
            }

            return(RedirectToAction("Login", "User"));
        }
 public ActionResult Login(Login login)
 {
     using (HalloweenEntities data = new HalloweenEntities())
     {
         var u = data.User.Where(a => a.Username == login.Username).FirstOrDefault();
         if (u != null)
         {
             if (string.Compare(login.Password, u.Password) == 0)
             {
                 Session["user"] = u.Username;
                 return(RedirectToAction("Index", "Home"));
             }
         }
         else
         {
             ViewBag.Message = "Invalid credential!!";
         }
         return(View());
     }
 }
Пример #10
0
        public ActionResult Details(string id)
        {
            Product p = new HalloweenEntities().Products.Where(prod => prod.ProductID == id).Single();

            return(View(p));
        }
Пример #11
0
        public ActionResult Products()
        {
            List <Product> products = new HalloweenEntities().Products.ToList();

            return(View(products));
        }