public virtual AjaxResult SearchCustomer([FromBody] Customer inputCustomer) { var ajaxResult = new AjaxResult(); try { ajaxResult.Data = _customerBL.SearchCustomer(inputCustomer); ajaxResult.Success = true; ajaxResult.Messanger = Properties.Resources.VN_SuccessSearch; } catch (Exception) { ajaxResult.Success = false; ajaxResult.Messanger = Properties.Resources.VN_ErrSearch; } return(ajaxResult); }
/// <summary> /// UI to view location order history /// </summary> private void ViewLocationOrderHistory() { bool repeat = true; string locationName = _validate.ValidateString("\nEnter the location you want to view"); Log.Information("Location name input"); try { // Search for specific location and retrieve orders Location location = _locationBL.GetLocation(locationName); List <Order> locationOrders = _orderBL.GetLocationOrders(location.Id); List <Order> sortedOrders = new List <Order>(); do { Console.WriteLine("How should the orders be sorted?"); Console.WriteLine("[1] Sort by Date (Newest to Oldest)"); Console.WriteLine("[2] Sort by Date (Oldest to Newest)"); Console.WriteLine("[3] Sort by Cost (Lowest to Highest)"); string input = Console.ReadLine(); switch (input) { case "1": Log.Information("Sort by Date Ascending Selected"); repeat = false; sortedOrders = locationOrders.OrderByDescending(ord => ord.OrderDate).ToList(); break; case "2": Log.Information("Sort by Date Descending Selected"); repeat = false; sortedOrders = locationOrders.OrderBy(ord => ord.OrderDate).ToList(); break; case "3": Log.Information("Sort by Cost Ascending Seleceted"); repeat = false; sortedOrders = locationOrders.OrderBy(ord => ord.Total).ToList(); break; default: // Invalid Input Console.WriteLine("Please input a valid option"); break; } } while (repeat); // Iterate through, orders, line items, and products to display order information foreach (Order order in sortedOrders) { Customer customer = _customerBL.SearchCustomer(order.CustomerID); List <LineItem> lineItems = _lineItemBL.GetLineItems(order.OrderID); Console.WriteLine($"\nCustomer Name: {customer.FirstName} {customer.LastName} \nLocation Name: {location.StoreName} \nOrder Date: {order.OrderDate}"); foreach (LineItem lineItem in lineItems) { List <Product> products = _productBL.GetAllProducts(); foreach (Product product in products) { if (product.Id.Equals(lineItem.ProductID)) { Console.WriteLine($"{lineItem.Quantity} {product.ItemName}"); } } } Console.WriteLine($"Order Total ${order.Total}\n"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }