예제 #1
0
        public ActionResult Create([Bind(Include = "CategoryId,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Create([Bind(Include = "ProducerId,Name")] Producer producer)
        {
            if (ModelState.IsValid)
            {
                db.Producers.Add(producer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(producer));
        }
        public ActionResult Create(Item item)
        {
            if (ModelState.IsValid)
            {
                db.Items.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", item.CategoryId);
            ViewBag.ProducerId = new SelectList(db.Producers, "ProducerId", "Name", item.ProducerId);
            return(View(item));
        }
예제 #4
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         var abc = order.OrderDate.ToShortDateString();
         var cd  = order.FirstName;
         System.Diagnostics.Debug.WriteLine(abc);
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
        public ActionResult LogOff()
        {
            SuperMarketDB storeDB   = new SuperMarketDB();
            var           cartItems = storeDB.Carts.Where(c => 1 == 1);

            foreach (var cartItem in cartItems)
            {
                storeDB.Carts.Remove(cartItem);
            }

            storeDB.SaveChanges();

            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);

            order.Username  = User.Identity.Name;
            order.OrderDate = DateTime.Now;
            order.Total     = Convert.ToInt32(TempData["tot"]);
            storeDB.Orders.Add(order);
            storeDB.SaveChanges();
            TempData["Firstname"] = values["Firstname"];
            TempData["Lastname"]  = values["Lastname"];

            var cart = ShoppingCart.GetCart(this.HttpContext);

            cart.CreateOrder(order);

            return(RedirectToAction("Complete",
                                    new { id = order.OrderId }));
        }