public IActionResult GetOrderForCustomer(int customerId, int orderId) { OrderWithDetailsAndProductInfo orderWithDetails = _repo.GetOneWithDetails(customerId, orderId); return(orderWithDetails == null ? (IActionResult)NotFound() : new ObjectResult(orderWithDetails)); }
public IActionResult Details(int orderId) { ViewBag.Title = "Order Details"; ViewBag.Header = "Order Details"; OrderWithDetailsAndProductInfo orderDetails = _orderRepo.GetOneWithDetails(orderId); if (orderDetails == null) { return(NotFound()); } return(View(orderDetails)); }
public async Task <IActionResult> Details(int customerId, int orderId) { ViewBag.Title = "Order Details"; ViewBag.Header = "Order Details"; OrderWithDetailsAndProductInfo orderDetails = await _webApiCalls.GetOrderDetailsAsync(customerId, orderId); if (orderDetails == null) { return(NotFound()); } return(View(orderDetails)); }
public async Task <IActionResult> Details(int orderId) { ViewBag.Title = "Order Details"; ViewBag.Header = "Order Details"; OrderWithDetailsAndProductInfo orderDetails = await _serviceWrapper.GetOrderDetailsAsync(orderId); if (orderDetails == null) { return(NotFound()); } return(View(orderDetails)); }
public OrderWithDetailsAndProductInfo GetOneWithDetails(int orderId) { var order = Table.IgnoreQueryFilters().Include(x => x.CustomerNavigation).FirstOrDefault(x => x.Id == orderId); if (order == null) { return(null); } var orderDetailsWithProductInfoForOrder = _orderDetailRepo.GetOrderDetailsWithProductInfoForOrder(order.Id); var orderWithDetailsAndProductInfo = OrderWithDetailsAndProductInfo.Create(order, order.CustomerNavigation, orderDetailsWithProductInfoForOrder); return(orderWithDetailsAndProductInfo); }
public async Task <IActionResult> Update(int customerId, int id, string billingAddress, string shippingAddress, string phone) { try { await _webApiCalls.UpdateOrderAddressAndPhone(customerId, id, billingAddress, shippingAddress, phone); OrderWithDetailsAndProductInfo orderDetails = await _webApiCalls.GetOrderDetailsAsync(customerId, id); return(RedirectToAction(nameof(Details), new { customerId, id })); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "An error occurred updating the address. Please reload the page and try again."); return(RedirectToAction(nameof(Details), new { customerId, id })); } }