예제 #1
0
 //
 // GET: /Sandwiches/Create
 public ActionResult Create(int id)
 {
     var sandwich = new OrderItem();
     sandwich.OrderID = id;
     if (db.Orders.Find(id) == null)
     {
         return RedirectToAction("Error");
     }
     ViewBag.OrderDate = db.Orders.Find(id).OrderDate;
     if (ViewBag.OrderDate < DateTime.Now.AddHours(-8))
     {
         return RedirectToAction("Error");
     }
     return View(sandwich);
 }
예제 #2
0
        public ActionResult Create(OrderItem orderitem)
        {
            if (ModelState.IsValid)
            {
                var user = Membership.GetUser();
                var eater = new PigEater();
                var profile = UserProfile.GetUserProfile();
                eater.UserId = user.ProviderUserKey.ToString();
                eater.FirstName = profile.FirstName;
                eater.LastName = profile.LastName;
                orderitem.Eater = eater;
                if (user.UserName.ToLower().Contains("joe"))
                {
                    orderitem.Other = null;
                }
                db.OrderItems.Add(orderitem);
                db.SaveChanges();
                return RedirectToAction("Index", new { id=orderitem.OrderID});
            }

            ViewBag.OrderID = new SelectList(db.Orders, "OrderID", "OrderID", orderitem.OrderID);
            return View(orderitem);
        }