OrderPartialClass.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Media;
  7. namespace OOO_WriteAndClear.DBModels
  8. {
  9. public partial class Order
  10. {
  11. public decimal OrderCost =>
  12. OrderProducts.Sum(a=> a.ProductArticleNumberNavigation.CurrentPrice * a.ProductAmount);
  13. public decimal OrderCostWithoutDiscount =>
  14. OrderProducts.Sum(a => a.ProductArticleNumberNavigation.ProductCost * a.ProductAmount);
  15. public decimal OrderDiscount => OrderCostWithoutDiscount - OrderCost;
  16. public decimal OrderDiscountPercent => 1 - (OrderCost / OrderCostWithoutDiscount);
  17. public SolidColorBrush OrderBackGround
  18. {
  19. get
  20. {
  21. SolidColorBrush brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#20b2aa");
  22. foreach (var item in OrderProducts)
  23. {
  24. if (item.ProductArticleNumberNavigation.ProductQuantityInStock == 0)
  25. {
  26. brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#ff8c00");
  27. break;
  28. }
  29. if (item.ProductArticleNumberNavigation.ProductQuantityInStock <= 3)
  30. {
  31. brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#ffffff");
  32. break;
  33. }
  34. }
  35. return brush;
  36. }
  37. }
  38. }
  39. }