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(...)
//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()
//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()); } }
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()); } }
public ActionResult Details(string id) { Product p = new HalloweenEntities().Products.Where(prod => prod.ProductID == id).Single(); return(View(p)); }
public ActionResult Products() { List <Product> products = new HalloweenEntities().Products.ToList(); return(View(products)); }