public ActionResult UpdateCustomer(CustomerChangeModel model) { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { CustomerService customerService = new CustomerService(); if (model.NewPassword != null) { if (model.NewPassword != model.ConfirmNewPassword) { TempData["Message"] = "二次驗證密碼錯誤"; return(RedirectToAction("Index", "Customer")); } else if (customerService.UpdateCustomerDetail(cookie.Username, model.NewPassword, model.CustomerName, model.Email, model.Phone, model.Address) == false) { TempData["Message"] = "更改失敗,稍後重試"; } return(RedirectToAction("Index", "Customer")); } if (customerService.UpdateCustomerDetail(cookie.Username, model.CustomerName, model.Email, model.Phone, model.Address) == false) { TempData["Message"] = "更改失敗,稍後重試"; } return(RedirectToAction("Index", "Customer")); } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("Index", "Home")); } }
public ActionResult ShoppingCart() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { try { OrdersService ordersService = new OrdersService(); ShoppingCartService shoppingCartService = new ShoppingCartService(); var shoppingcart = shoppingCartService.GetAccountCart(cookie.Username); if (shoppingcart.Count() == 0) { TempData["Message"] = "購物車是空的,返回上一頁"; return(Redirect(Request.UrlReferrer.ToString())); } ViewBag.totalmoney = shoppingcart.Sum(x => x.RowPrice); return(View(shoppingcart)); } catch { TempData["Message"] = "錯誤,稍後重試"; return(Redirect(Request.UrlReferrer.ToString())); } } else { TempData["Message"] = "請先登入會員"; return(Redirect(Request.UrlReferrer.ToString())); } }
public ActionResult GetProducts() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Employee) { ProductService productService = new ProductService(); return(View(productService.GetProductOfBackstage())); } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("AdminLoginPage", "Login")); } }
public ActionResult GetOrdersStatus(int status) { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Employee) { OrdersService ordersService = new OrdersService(); return(View(ordersService.GetOrders(status))); } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("AdminLoginPage", "Login")); } }
public ActionResult GetOrders(string Account) { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Employee) { TempData["Account"] = Account; return(View()); } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("AdminLoginPage", "Login")); } }
public ActionResult CreateOrder(string Pay, string Transport) { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); switch (cookie.Status) { case cookieStatus.Match: OrdersService ordersService = new OrdersService(); TempData["Message"] = ordersService.CreateOrder(cookie.Username, Pay, Transport, 60); return(RedirectToAction("completeOrder")); default: TempData["Message"] = "請先登入會員"; return(Redirect(Request.UrlReferrer.ToString())); } }
public ActionResult LoginPage() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { ViewBag.IsAuthenticated = true; ViewBag.Username = cookie.Username; return(PartialView()); } else { ViewBag.IsAuthenticated = false; return(View()); } }
// GET: BackStage public ActionResult Index() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Employee) { OrdersService ordersService = new OrdersService(); CustomerService customerService = new CustomerService(); ViewBag.OrdersNum = ordersService.GetOrders(false); ViewBag.NewOrdersNum = ordersService.GetOrders(true); ViewBag.CustomerNum = customerService.GetAll().Count(); return(View()); } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("AdminLoginPage", "Login")); } }
// GET: ShoppingCart public ActionResult AddtoShoppingCart(int ID, string Name, string color, string size, int quantity) { //cookie 丟進去 CookieCheck 類別裡面的 static function 做處理 var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); //如果沒有選擇顏色或尺寸就回傳錯誤訊息 請他選擇尺寸與顏色 if (color == "" || size == "") { TempData["Message"] = "請選擇顏色與尺寸"; return(Redirect(Request.UrlReferrer.ToString())); } //如果cookie 符合 登錄的資料 還有他的角色是顧客 他就可以使用加入購物車的動作 if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { try { //宣告一個 ShoppingCartService 的執行個體 ShoppingCartService shoppingCartService = new ShoppingCartService(); //ShoppingCartService 裡面的 CreateShoppingCart 會回傳 布林 如果是 true 就是加入成功 反之亦然 //右鍵 CreateShoppingCart 然後去移置定義 if (shoppingCartService.CreateShoppingCart(cookie.Username, ID, quantity, size, color)) { TempData["Message"] = "加入" + Name + "到購物車"; } else { TempData["Message"] = Name + " 庫存不足"; } } catch { TempData["Message"] = "錯誤,稍後重試"; return(Redirect(Request.UrlReferrer.ToString())); } } else { TempData["Message"] = "請先登入會員"; return(Redirect(Request.UrlReferrer.ToString())); } return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult GetStocks(int?Product_ID) { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Employee) { StockService stockService = new StockService(); if (Product_ID == null) { return(View(stockService.GetAll())); } else { ViewBag.notall = 0; return(View(stockService.GetProduct_ID((int)Product_ID))); } } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("AdminLoginPage", "Login")); } }
// GET: Customer public ActionResult Index() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { try { CustomerService customerService = new CustomerService(); return(View(customerService.GetCustomerDetail(cookie.Username))); } catch { TempData["Message"] = "錯誤,稍後重試"; return(RedirectToAction("Index", "Home")); } } else { TempData["Message"] = "請先登入會員"; return(RedirectToAction("Index", "Home")); } }
public ActionResult CompleteOrder() { var cookie = CookieCheck.check(Request.Cookies[FormsAuthentication.FormsCookieName]); if (cookie.Status == cookieStatus.Match && cookie.Authority == Character.Customer) { try { OrdersService ordersService = new OrdersService(); var result = ordersService.GetNewOrders(cookie.Username); return(View(result)); } catch { TempData["Message"] = "錯誤,稍後重試"; return(Redirect(Request.UrlReferrer.ToString())); } } else { TempData["Message"] = "請先登入會員"; return(Redirect(Request.UrlReferrer.ToString())); } }