ProductPartialClass.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Media.Imaging;
  8. namespace OOO_WriteAndClear.DBModels
  9. {
  10. public partial class Product
  11. {
  12. public BitmapImage ProductImage
  13. {
  14. get
  15. {
  16. BitmapImage image = new BitmapImage();
  17. if (this.ProductPhoto is null || this.ProductPhoto.Length == 0)
  18. {
  19. image.BeginInit();
  20. image.UriSource = new Uri(Environment.CurrentDirectory + "\\Assets\\Pictures\\ProductPictures\\picture.png", UriKind.RelativeOrAbsolute);
  21. image.CacheOption = BitmapCacheOption.OnLoad;
  22. image.EndInit();
  23. return image;
  24. }
  25. image.BeginInit();
  26. image.UriSource = new Uri(Environment.CurrentDirectory + "\\Assets\\Pictures\\ProductPictures\\" + ProductPhoto, UriKind.RelativeOrAbsolute);
  27. image.CacheOption = BitmapCacheOption.OnLoad;
  28. image.EndInit();
  29. return image;
  30. }
  31. }
  32. public decimal CurrentPrice
  33. {
  34. get
  35. {
  36. decimal Discount = ProductDiscountMax is null? 0m : (decimal)ProductDiscountMax;
  37. return ProductCost * ((100m - Discount) / 100m);
  38. }
  39. }
  40. public bool IsBiggerThan15PercentDiscount => ProductDiscountMax > 15;
  41. }
  42. }