public ActionResult Index() { _logger.Info("Get all orders"); Customer currentCustomer = _customerAccountService.GetCustomer((int)Session["AccountId"]); _logger.InfoFormat("All orders count : [{0}]", currentCustomer.Orders.Count); if (currentCustomer.Orders.Count == 0) { return(RedirectToAction("NoOrders")); } return(View(currentCustomer.Orders)); }
public ActionResult RepeatOrder(int orderId) { _logger.InfoFormat("Repeat order with id [{0}].", orderId); var customer = _customerAccountService.GetCustomer((int)Session["AccountId"]); Order order = customer.Orders.FirstOrDefault(o => o.Id == orderId); if (order == null) { return(View("Index", (Cart)Session["Cart"])); } Item itemToAdd; foreach (var item in order.Cart.Items) { itemToAdd = _itemQueryService.GetItem(item.Item.Id); if (itemToAdd != null) { FormCollection fc = new FormCollection { ["itemId"] = Convert.ToString(itemToAdd.Id), ["quantity"] = Convert.ToString(item.Quantity) }; AddToCart(fc); } } _logger.InfoFormat("Items from order with id [{0}] were successfully added to cart.", orderId); return(View("Index", (Cart)Session["Cart"])); }
private void GetSessionCustomer(out Customer customer) //TODO: enough to return Customer.Id? { int?customerId = (int?)Session["AccountId"]; customer = _customerAccountService.GetCustomer((int)customerId); }
public ActionResult Edit() { return(View(_customerAccountService.GetCustomer((int)Session["AccountId"]))); }