private void DisplayRevenueByCategory() { SeriesCollection series = new SeriesCollection(); List <Category> categories = CategoriesDAO.GetCategories(); categories = categories.Skip(1).ToList(); List <CartItem> cartItems = new List <CartItem>(); foreach (var order in orders) { cartItems.AddRange(order.CartItems); } foreach (var category in categories) { long value = 0; foreach (var cartItem in cartItems) { if (cartItem.Cake.Category.Id == category.Id) { value += cartItem.TotalPrice; } } PieSeries pieSeries = new PieSeries { Title = category.Name, Values = new ChartValues <long> { value }, DataLabels = true, LabelPoint = PointLabel }; series.Add(pieSeries); } revenueByCategoryPie.Series = series; }
private void DisplayDetail() { cake = CakesDAO.GetById(idCake); var folder = AppDomain.CurrentDomain.BaseDirectory; var pathImageAbsolute = $"{folder}\\Assets\\Images\\Uploads\\{cake.Image_Main}"; imageUploadImage.Source = new BitmapImage(new Uri(pathImageAbsolute, UriKind.Absolute)); categories = CategoriesDAO.GetCategories(); categoryComboBox.ItemsSource = categories; categoryComboBox.SelectedIndex = categories.FindIndex(item => item.Id == cake.Category.Id); imageUploadImage.Tag = cake.Image_Main; nameImage = cake.Image_Main; this.DataContext = cake; }