Пример #1
0
 public ActionResult Create([Bind(Include = "SizeID,SizeTitle,SizeContext")] Size size)
 {
     if (ModelState.IsValid)
     {
         db.Sizes.Add(size);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(size));
 }
Пример #2
0
 public ActionResult Create([Bind(Include = "ColorID,ColorName")] Color color)
 {
     if (ModelState.IsValid)
     {
         db.Colors.Add(color);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(color));
 }
Пример #3
0
 public ActionResult Create([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,Name,City,Country,Address,ZipCode,BankAccount,CreditCard")] AspNetUser aspNetUser)
 {
     if (ModelState.IsValid)
     {
         db.AspNetUsers.Add(aspNetUser);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aspNetUser));
 }
Пример #4
0
 public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Categories.Add(category);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Пример #5
0
        public ActionResult Create([Bind(Include = "ShipperID,ShippName,Phone")] Shipper shipper)
        {
            if (ModelState.IsValid)
            {
                db.Shippers.Add(shipper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shipper));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "DDID,ProductID,Detail")] DesDetail desDetail)
        {
            if (ModelState.IsValid)
            {
                db.DesDetails.Add(desDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", desDetail.ProductID);
            return(View(desDetail));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "ImgID,PDID,ImgName")] Image image)
        {
            if (ModelState.IsValid)
            {
                db.Images.Add(image);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PDID = new SelectList(db.ProductDetails, "PDID", "PDID", image.PDID);
            return(View(image));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "DSTID,ProductID,SubTitle")] DesSubTitle desSubTitle)
        {
            if (ModelState.IsValid)
            {
                db.DesSubTitles.Add(desSubTitle);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", desSubTitle.ProductID);
            return(View(desSubTitle));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "ProductID,ProductName,CategoryID,UnitPrice")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
            return(View(product));
        }
Пример #10
0
        public ActionResult Create([Bind(Include = "OrderID,UserID,ShippingID,RecipientName,RecipientAddressee,RecipientZipCod,RecipientCity,RecipientPhone,Payment,OrderDate,Remaeks,ShipDate")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID     = new SelectList(db.AspNetUsers, "Id", "Email", order.UserID);
            ViewBag.ShippingID = new SelectList(db.Shippers, "ShipperID", "ShippName", order.ShippingID);
            return(View(order));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "PDID,OrderID,Price,Quantity,Discount")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderID = new SelectList(db.Orders, "OrderID", "OrderID", orderDetail.OrderID);
            ViewBag.PDID    = new SelectList(db.ProductDetails, "PDID", "PDID", orderDetail.PDID);
            return(View(orderDetail));
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "PDID,ProductID,Stock,SizeID,ColorID")] ProductDetail productDetail)
        {
            if (ModelState.IsValid)
            {
                db.ProductDetails.Add(productDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ColorID   = new SelectList(db.Colors, "ColorID", "ColorName", productDetail.ColorID);
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", productDetail.ProductID);
            ViewBag.SizeID    = new SelectList(db.Sizes, "SizeID", "SizeContext", productDetail.SizeID);
            return(View(productDetail));
        }
Пример #13
0
        public ActionResult Create([Bind(Include = "SupportID,UserID,SupportCategoryID,SupportTitle,SupportContent,StatusID,SupportTime")] Support support)
        {
            List <Support> supports = db.Supports.ToList();

            support.SupportID   = supports.LastOrDefault().SupportID + 1;
            support.SupportTime = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Supports.Add(support);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID            = new SelectList(db.AspNetUsers, "Id", "Email", support.UserID);
            ViewBag.StatusID          = new SelectList(db.Status, "StasusID", "StatusName", support.StatusID);
            ViewBag.SupportCategoryID = new SelectList(db.SupportCategories, "SupportCategoryID", "SupportCategoryName", support.SupportCategoryID);
            return(View(support));
        }
Пример #14
0
        public ActionResult Order_Pay(OrderCustomerViewModel Bill_OCVM, bool Order_Pay_Radio)  //下單-付費頁面!沒有HEADER跟FOOTER
        {
            var OCVM = (OrderCustomerViewModel)Session["Order_Session"];

            ViewData["CustomerName"] = OCVM.CustomerName;
            ViewData["City"]         = OCVM.City;
            ViewData["ZipCode"]      = OCVM.ZipCode;
            ViewData["Address"]      = OCVM.Address;
            ViewData["Phone"]        = OCVM.Phone;
            ViewData["Email"]        = OCVM.Email;

            if (Order_Pay_Radio)
            {
                Session["Bill_Order_Seccion"] = Bill_OCVM;
                ViewData["Bill_CustomerName"] = Bill_OCVM.Bill_CustomerName;
                ViewData["Bill_City"]         = Bill_OCVM.Bill_City;
                ViewData["Bill_ZipCode"]      = Bill_OCVM.Bill_ZipCode;
                ViewData["Bill_Address"]      = Bill_OCVM.Bill_Address;
                ViewData["Bill_Phone"]        = Bill_OCVM.Bill_Phone;
            }

            //SQL

            var           REPO_O  = new Repositories.KumaRepository <Order>(db);
            var           REPO_OD = new Repositories.KumaRepository <OrderDetail>(db);
            Random        rnd     = new Random();
            List <string> name    = new List <string>()
            {
                "風志淇", "風志聞", "風志來", "風志可", "風志成", "風志偉"
            };
            List <string> country = new List <string>()
            {
                "Taiwan 台灣", "Thailand 泰國", "Sweden 瑞典", "Poland 波蘭", "Russia 俄羅斯", "Malaysia 馬來西亞", "Japan 日本", "India 印度", "United States 美國"
            };
            List <string> payment = new List <string>()
            {
                "銀行轉帳", "信用卡/VISA金融卡", "貨到付款"
            };
            List <string> zipCode = new List <string>()
            {
                "300", "226", "267", "413", "362", "649", "901"
            };
            List <string> city = new List <string>()
            {
                "Keelung", "Taipei", "Hsinchu", "Taichung", "Tainan", "Kaohsiung", "Yilan", "Taoyuan", "Miaoli", "Changhua", "Nantou"
            };
            List <string> address = new List <string>()
            {
                "No. 1, Sec. 4, Roosevelt Rd., Da’an Dist.", "No. 2, Ln. 456, Sec. 1, Xinsheng S. Rd., Da’an Dist.", "No. 456, Sec. 2, Heping E. Rd., Da’an Dist.", "No. 85, Sec. 1, Jianguo S. Rd., Da’an Dist.",
                "No. 85, Sec. 1, Jianguo S. Rd., Da’an Dist.", "No. 67, Sec. 2, Yangde Blvd., Shilin Dist.", "No. 865, Yishou St., Wenshan Dist."
            };
            List <string> phone = new List <string>()
            {
                "+639051234567", "+817012345678", "+85261234567", "+12042345678", "+5491123456789", "+358412345678"
            };
            List <decimal> fare = new List <decimal>()
            {
                60, 60, 60, 80, 90
            };
            var O = new Order();

            // 存到Order資料庫
            O.RecipientName      = name[rnd.Next(name.Count)];
            O.RecipientCity      = city[rnd.Next(city.Count)];
            O.RecipientZipCod    = zipCode[rnd.Next(zipCode.Count)];
            O.RecipientAddressee = address[rnd.Next(address.Count)];
            O.RecipientPhone     = phone[rnd.Next(phone.Count)];
            int n = rnd.Next(fare.Count);

            O.ShippingID       = n + 1;
            O.Fare_now         = fare[n];
            O.RecipientCountry = country[rnd.Next(country.Count)];

            var Userid = User.Identity.GetUserId();

            O.UserID = Userid;
            //因為目前只有轉帳功能
            O.Payment = payment[rnd.Next(payment.Count)];
            if (Session["Remark"] == null)
            {
                O.Remaeks = null;
            }
            else
            {
                O.Remaeks = Session["Remark"].ToString();
            }
            O.OrderDate  = DateTime.Now;
            O.StatusID   = 7;
            O.TotalPrice = 0;
            //O.ShipDate = DateTime.Now.AddHours(1);

            REPO_O.Create(O);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            var OrderList = db.Orders.ToList();
            var OrderID   = OrderList.Last().OrderID;

            var REPO_PD = new KumaRepository <ProductDetail>(db);
            var PDs     = db.ProductDetails.ToList();

            if ((bool)Session["CartToHere"])
            {
                var currentCart = CartService.GetCurrentCart();
                foreach (var item in currentCart)
                {
                    //新增訂單
                    var OD = new OrderDetail();
                    OD.PDID     = item.PDID;
                    OD.OrderID  = OrderID;
                    OD.Price    = item.Amount;
                    OD.Quantity = item.Quantity;
                    REPO_OD.Create(OD);

                    //修正物品庫存量
                    var pd = PDs.FirstOrDefault(x => x.PDID == OD.PDID);
                    pd.Stock -= OD.Quantity;
                    REPO_PD.Update(pd);
                }
                //加入Order總金額
                try
                {
                    O = db.Orders.ToList().LastOrDefault(x => x.OrderID == OrderID);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                O.TotalPrice = currentCart.TotalAmount + OCVM.Fare;
                REPO_O.Update(O);
            }
            else // BuyItNow
            {
                //新增訂單
                var OD       = new OrderDetail();
                var BuyItNow = (BuyOneViewModel)Session["BuyItNow"];
                OD.PDID     = BuyItNow.CartItem.PDID;
                OD.OrderID  = OrderID;
                OD.Price    = BuyItNow.CartItem.UnitPrice;
                OD.Quantity = BuyItNow.CartItem.Quantity;
                REPO_OD.Create(OD);
                //加入Order總金額
                try
                {
                    O = db.Orders.ToList().LastOrDefault(x => x.OrderID == OrderID);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                O.TotalPrice = BuyItNow.CartItem.Amount + OCVM.Fare;
                REPO_O.Update(O);

                //修正物品庫存量
                var pd = PDs.FirstOrDefault(x => x.PDID == OD.PDID);
                pd.Stock -= OD.Quantity;
                REPO_PD.Update(pd);
            }
            db.SaveChanges();

            //初始化
            Session["Remark"] = null;
            ViewData.Model    = CartService.GetCurrentCart();
            ViewBag.Img       = CartService.getEachProductImages(db);
            //購買完成,清除購物車
            CartService.ClearCart();
            return(View("Order_Check"));
        }