// GET: CustomerInformation/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶資料 客戶資料 = CustomerRepo.Find(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }

            var items = (from p in classification
                         select p.Key)
                        .Distinct()
                        .OrderBy(p => p)
                        .Select(p => new SelectListItem()
            {
                Text  = classification[p].ToString(),
                Value = p.ToString()
            });

            ViewBag.客戶分類 = new SelectList(items, "Value", "Text", 客戶資料.客戶分類);

            return(View(客戶資料));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            客戶資料 客戶資料 = CustomerRepo.Find(id);

            CustomerRepo.Delete(客戶資料);
            CustomerRepo.UnitOfWork.Commit();

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        // GET: /<controller>/
        public IActionResult GetById(int id)
        {
            var customer = CustomerRepo.Find(id);

            if (customer == null)
            {
                return(NotFound());
            }

            return(new ObjectResult(customer));;
        }
        // GET: CustomerInformation/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶資料 客戶資料 = CustomerRepo.Find(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶資料));
        }
Beispiel #5
0
        public void addProductToBasket(int customerId, Product product)
        {
            Customer customer = CustomerRepo.Find(customerId);

            customer.Basket.Products.Add(product);
            List <Product> basketProducts = (System.Collections.Generic.List <HarambeExercise.Models.Product>)customer.Basket.Products;

            foreach (Bundle bundle in BundleRepo.GetAll())
            {
                List <Product> bundleProducts = (System.Collections.Generic.List <HarambeExercise.Models.Product>)bundle.Products;
                if (ContainsAllItems(basketProducts, bundleProducts))
                {
                    customer.Basket.Value = bundle.Value;
                }
            }
        }
        [ChildActionOnly]//限定由頁面呼叫存取
        public ActionResult CustomerContactList(int id)
        {
            ViewData.Model = CustomerRepo.Find(id).客戶聯絡人.ToList();

            return(PartialView("CustomerContactList"));
        }
Beispiel #7
0
 public Customer GetCustomer(int id)
 {
     return(customerRepo.Find(id));
 }
Beispiel #8
0
        public double GetBasketCurrentValue(int customerId)
        {
            Customer customer = CustomerRepo.Find(customerId);

            return(BasketRepo.GetBasketCurrentValue(customer.Basket.CartId));
        }