| | 1 | | using MRA.DTO.Enums.Drawing; |
| | 2 | | using MRA.DTO.Models; |
| | 3 | | using MRA.Infrastructure.Enums; |
| | 4 | |
|
| | 5 | | namespace MRA.DTO.ViewModels.Art.Select; |
| | 6 | |
|
| | 7 | | public class ProductListItem |
| | 8 | | { |
| 33 | 9 | | public string ProductName { get; set; } |
| 0 | 10 | | public int ProductTypeId { get => (int)ProductType; } |
| 11 | 11 | | public DrawingProductTypes ProductType { get; set; } |
| | 12 | |
|
| 11 | 13 | | public ProductListItem(string productName, DrawingProductTypes productType) |
| | 14 | | { |
| 11 | 15 | | ProductName = productName; |
| 11 | 16 | | ProductType = productType; |
| 11 | 17 | | } |
| | 18 | |
|
| | 19 | | public static IEnumerable<ProductListItem> GetProductsFromDrawings(IEnumerable<DrawingModel> drawings) |
| | 20 | | { |
| 1 | 21 | | return drawings |
| 8 | 22 | | .Where(x => !string.IsNullOrEmpty(x.ProductName)) |
| 8 | 23 | | .Select(x => new ProductListItem(x.ProductName, x.ProductType.ToEnum<DrawingProductTypes>())) |
| 1 | 24 | | .Distinct(); |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public override bool Equals(object obj) |
| | 28 | | { |
| 7 | 29 | | return GetHashCode() == obj.GetHashCode(); |
| | 30 | | } |
| | 31 | |
|
| | 32 | | public override int GetHashCode() |
| | 33 | | { |
| 22 | 34 | | return HashCode.Combine(ProductName); |
| | 35 | | } |
| | 36 | | } |