示例#1
0
        public ActionResult FindCustomer(Customer customer, string loginEmail)
        {
            if(Request.Form["SubmitLogin"] != null)
            {
                customer = Facade.GetCustomerGateway().search(loginEmail);
                if(customer == null)
                {
                    ViewBag.LoginError = "Ingen kunde fundet på emailen.";
                    return View();
                }
                else
                {
                    return RedirectToAction("PlaceOrder", customer);
                }
            }
            else if(Request.Form["SubmitCreate"] != null)
            {
                if (ModelState.IsValid)
                {

                    return RedirectToAction("PlaceOrder", customer);
                }
                else
                {
                    return View();
                }
            }

            return View();
        }
示例#2
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                Facade.GetCustomerRepository().Create(customer);
                return RedirectToAction("Index");
            }

            CreateEditCustomerViewModel createEditCustomerViewModel = new CreateEditCustomerViewModel();
            return View(createEditCustomerViewModel);
        }
示例#3
0
        public ActionResult PlaceOrder(Customer customer)
        {
            if(Session["Cart"] == null)
            {
                return RedirectToAction("Index");
            }
            Orders order = new Orders();
            order.customer = customer;
            order.orderTime = DateTime.Now;
            order.shoppingCartItems = (List<ShoppingCartItem>)Session["Cart"];

            Facade.GetOrderGateway().Create(order);

            Session["Cart"] = null;
            return View();
        }