public ActionResult AddUserToDB(FormCollection fomr) { using (AdvancedWebDevelopmentEntities1 context = new AdvancedWebDevelopmentEntities1()) { CustomerData customer = new CustomerData(); customer.Name = fomr["name"]; customer.Surname = fomr["surname"]; customer.Mail = fomr["mail"]; customer.Phone = fomr["phone"]; customer.Password = fomr["password"]; context.CustomerData.Add(customer); context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Cart() { List <ProductInfo> productlist = new List <ProductInfo>(); using (AdvancedWebDevelopmentEntities1 context = new AdvancedWebDevelopmentEntities1()) { foreach (ProductInfo product in context.ProductInfo) { if (product.Product_State.ToString() == "OnCart ") { productlist.Add(product); } } } ViewBag.productlistt = productlist; return(View()); }
public ActionResult SignIn(FormCollection fomr) { using (AdvancedWebDevelopmentEntities1 context = new AdvancedWebDevelopmentEntities1()) { foreach (CustomerData customer in context.CustomerData) { if (fomr["mail"] == customer.Mail) { if (fomr["password"] == customer.Password) { Session["signin"] = "1"; Session["UserID"] = customer.ID; break; } } } } return(RedirectToAction("Index")); }
public ActionResult Buy(int id) { var a = id; using (AdvancedWebDevelopmentEntities1 context = new AdvancedWebDevelopmentEntities1()) { //Cart_Items cartitems = new Cart_Items(); //cartitems.Product_ID = id; //context.Cart_Items.Add(cartitems); ProductInfo prod = context.ProductInfo.Find(id); prod.Buyer_ID = Int32.Parse(Session["UserID"].ToString()); prod.Product_State = "OnCart"; context.SaveChanges(); //var prd = context.ProductInfo.Find(id); //context.ProductInfo.Remove(prd); //context.SaveChanges(); } return(RedirectToAction("Index")); }