Пример #1
0
        //客戶購物車清單 ==> 訂單
        public ActionResult OrderPayment()
        {
            if (String.IsNullOrEmpty((string)Session["logState"])) //如未登入,則重導到登入頁面
            {
                Session["lastPage"] = "/Order/OrderPayment";       //儲存最後頁面
                return(RedirectToAction("Login", "Member"));       //重導到登入頁面
            }
            //將存在session中的 電話取出
            string phonString = Session["userPhone"].ToString();
            //將存在session中的 桌號取出
            int tableNum = Convert.ToInt32(Session["TableId"]);
            //int tableNum = 1;

            //現在時間字串
            string dateString = DateTime.Now.ToString();

            if (this.ModelState.IsValid)
            {
                //取得購物車
                var currentCart = Models.Cart.Operation.GetCurrentCart();

                using (FoodCourtDBEntities db = new FoodCourtDBEntities()) {
                    //新增訂單,存入database
                    Models.Order newOrder = new Order()
                    {
                        orderDate  = dateString,
                        phoneNum   = phonString,
                        tableId    = tableNum,
                        orderState = 1, //訂單狀態:1-未結單 2-結單
                    };
                    db.Orders.Add(newOrder);
                    db.SaveChanges();

                    //傳入訂單編號,取得訂單明細,存入database
                    var newOrderDetail = currentCart.ToOrderDetail(newOrder.orderId);
                    db.OrderDetials.AddRange(newOrderDetail);
                    db.SaveChanges();

                    //signalR
                    var querySignalr = from o in newOrderDetail
                                       join p in db.Products on o.productID equals p.productID into r
                                       from p in r.DefaultIfEmpty()
                                       join q in task03_0606.Hubs.StoreHub.signalrsList on p.storeId equals q.StoreId into s
                                       from q in s.DefaultIfEmpty()
                                       group p by new { p.storeId, q.ContextID } into g
                    select g.Key.ContextID;
                    var context = GlobalHost.ConnectionManager.GetHubContext <StoreHub>();
                    foreach (var item in querySignalr)
                    {
                        context.Clients.Client(item).addNewMessageToPage("新訂單");
                    }
                } //return Content("訂購成功");



                return(RedirectToAction("ClearFromCart", "Cart"));
            }
            return(View());
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int productID)
        {
            Product product = db.Products.Find(productID);

            db.Products.Remove(product);
            db.SaveChanges();
            return(RedirectToAction("ManagerIndex"));
        }
Пример #3
0
 public ActionResult Order_list_bussiness(int orderId_ok)
 {
     using (Models.FoodCourtDBEntities db = new FoodCourtDBEntities()) {
         var order = (from o in db.Orders
                      where o.orderId == orderId_ok
                      select o).FirstOrDefault();
         order.orderState = 2;
         db.SaveChanges();
         return(Json(true));
     }
 }
Пример #4
0
        //廠商未出餐點明細清單 ==> 準備完成
        public ActionResult Order_list_chickToDatabase_bussiness(int productId_ok, int orderId_ok)
        {
            int test = productId_ok;

            using (Models.FoodCourtDBEntities db = new FoodCourtDBEntities()) {
                var result = (from o in db.OrderDetials
                              where o.productID == productId_ok && o.orderId == orderId_ok
                              orderby o.orderId
                              select o).FirstOrDefault();

                if (result.productionStatus == 1)
                {
                    result.productionStatus = 2;
                }
                else
                {
                    result.productionStatus = 1;
                }


                db.SaveChanges();
                return(Json(true));
            }
        }
Пример #5
0
        public ActionResult EasyRegister(string LastName, string FirstName, string Password1, string ConfirmPassword, string cellPhone)    //只需手機號碼的註冊
        //post時,回傳已填入值
        {
            int checkNum = 0;                    //用於檢查必填欄位是否填寫

            if (!string.IsNullOrEmpty(LastName)) //傳姓氏值
            {
                ViewBag.LastName = LastName;
                checkNum        += 1;
            }

            if (!string.IsNullOrEmpty(FirstName))   //傳名稱值
            {
                ViewBag.FirstName = FirstName;
                checkNum         += 1;
            }

            if (!string.IsNullOrEmpty(cellPhone))   //傳cellPhone值
            {
                ViewBag.cellPhone = cellPhone;
                checkNum         += 1;
            }
            //檢查電話是否註冊----------------------------------
            var queryCheckPhone = from o in db.UserInfoes
                                  where o.phoneNum == cellPhone
                                  select cellPhone;

            ViewBag.phoneCheck = "";

            if (queryCheckPhone.Count() > 0)
            {
                ViewBag.phoneCheck = "號碼已註冊";
                ViewBag.html       = "<i class='fa fa-times' style='color: red; '></i> 此號碼已註冊";
            }

            if (ViewBag.phoneCheck == "信箱已註冊")
            {
                return(View());
            }
            else
            {
                if (Password1 == ConfirmPassword && checkNum == 3)
                {
                    UserInfo addMember = new UserInfo()
                    {
                        lastName  = LastName,
                        firstName = FirstName,
                        pwd       = Password1,
                        phoneNum  = cellPhone,
                        userRank  = "normalUser",
                        userState = 1
                    };
                    db.UserInfoes.Add(addMember);
                    db.SaveChanges();
                    //try {
                    //    db.SaveChanges();
                    //} catch (Exception ex) {
                    //    throw;
                    //}
                    return(RedirectToAction("Login", "Member"));
                }
            }

            return(View());
        }