| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
-
- using qdr.app.studiou.orders2printpack.Extensions;
- using System.Security.Policy;
- using System.Text;
- namespace qdr.app.studiou.orders2printpack.ProductStorage
- {
- public class ProductDto : IIdentifierGetter
- {
- public const string CS_ITEM_TYPE_VARIANT = "variation";
- public const string CS_ITEM_TYPE_PRODUCT = "variable";
- [CsvColumn("ID")]
- public int Id { get; set; }
- [CsvColumn("Typ")]
- public string Type { get; set; } = string.Empty;
- [CsvColumn("Katalogové číslo")]
- public string Sku { get; set; } = string.Empty;
-
- [CsvColumn("Jméno")]
- public string ProductName { get; set; } = string.Empty;
- [CsvColumn("Nadřazené")]
- public string ParentName { get; set; } = string.Empty;
- [CsvColumn("Krátký popis")]
- public string ShortDescription { get; set; } = string.Empty;
- [CsvColumn("Popis")]
- public string Description { get; set; } = string.Empty;
- [CsvColumn("Název 1 vlastnosti")]
- public string VariantType { get; set; } = string.Empty;
- [CsvColumn("Hodnota(y) 1 vlastnosti")]
- public string VariantName { get; set; } = string.Empty;
- [CsvColumn("Kategorie")]
- public string Category { get; set; } = string.Empty;
-
- [CsvColumn("Obrázky")]
- public string Uri { get; set; } = string.Empty;
-
- [CsvColumn("Běžná cena")]
- public decimal Price { get; set; }
- [CsvColumn("Vlastnost 1 viditelnost")]
- public int Hidden1 { get; set; } = 1;
- [CsvColumn("Vlastnost 1 globální")]
- public int Hidden2 { get; set; } = 1;
- [CsvColumn("Povolit zákaznické recenze?")]
- public int Hidden3 { get; set; } = 0;
- public bool IsParentValid {get;set;}
- public bool IsValid => ((IsVariant && IsParentValid) || !IsVariant) && ((IsVariant && Price > 0) || !IsVariant) && !string.IsNullOrEmpty(Sku) && !string.IsNullOrEmpty(Uri) && ((!IsVariant && !string.IsNullOrEmpty(Category)) || IsVariant) && ((IsVariant && !string.IsNullOrEmpty(VariantName)) || !IsVariant);
- public bool IsVariant => string.Equals(Type, CS_ITEM_TYPE_VARIANT, StringComparison.InvariantCultureIgnoreCase);
- public string VariantAndPrice => $"{VariantName}-{Price}";
- public string TypeAsString => IsVariant ? "Varianta" : "Produkt";
- public string GetIdentifier()
- {
- var sb = new StringBuilder();
- sb.Append(Id).Append("_");
- sb.Append(ProductName);
- return sb.ToString().ToLower();
- }
- public void CopyTo(ProductDto destination, bool includeId = false)
- {
- if (includeId)
- destination.Id = Id;
- destination.Type = Type;
- destination.Sku = Sku;
- destination.ProductName = ProductName;
- destination.ParentName = ParentName;
- destination.ShortDescription = ShortDescription;
- destination.Description = Description;
- destination.VariantType = VariantType;
- destination.VariantName = VariantName;
- destination.Category = Category;
- destination.Uri = Uri;
- destination.Price = Price;
- }
- bool IEquatable<IIdentifierGetter>.Equals(IIdentifierGetter? other)
- {
- return other != null && other.GetIdentifier() == GetIdentifier();
- }
- }
- }
|