// GET: /Order/List public IActionResult List() { var orderEntities = _orderService.GetAllOrders(); var orderList = new List <OrderListModel>(); foreach (var order in orderEntities) { // get billing address var billingAddressEntity = _billingAddressService.GetBillingAddressById(order.BillingAddressId); if (billingAddressEntity != null) { var orderListModel = new OrderListModel { Id = order.Id, OrderNumber = order.OrderNumber, Name = billingAddressEntity.FirstName + " " + billingAddressEntity.LastName, Email = billingAddressEntity.Email, Status = order.Status.ToString(), OrderPlacementDateTime = order.OrderPlacementDateTime, TotalOrderPrice = order.TotalOrderPrice }; orderList.Add(orderListModel); } } return(View(orderList.OrderByDescending(x => x.OrderPlacementDateTime))); }
public async Task <IActionResult> GetBillingAddress() { if (Session.GetString("BillingAddress") != null) { return(Json(JsonConvert.DeserializeObject <BillingAddress>(Session.GetString("BillingAddress")))); } var user = await GetCurrentUserAsync(); var billingAddressEntity = _billingAddressService.GetBillingAddressById(user.BillingAddressId); if (billingAddressEntity == null) { return(Json(null)); } var billingAddressModel = _mapper.Map <BillingAddress, BillingAddressModel>(billingAddressEntity); return(Json(billingAddressEntity)); }
public async Task <IActionResult> Checkout() { if (Session.GetString(_cartItesmSessionKey) == null) { return(View("Index")); } var user = await GetCurrentUserAsync(); var checkoutModel = new CheckoutModel(); var cartItems = JsonConvert.DeserializeObject <List <CartItemModel> >(Session.GetString(_cartItesmSessionKey)); var billingAdddressEntity = _billingAddressService.GetBillingAddressById(user.BillingAddressId); if (billingAdddressEntity != null) { Session.SetString("BillingAddress", JsonConvert.SerializeObject(billingAdddressEntity)); ViewData["BillingAddress"] = true; } checkoutModel.CartItemModel = cartItems; return(View(checkoutModel)); }