491 lines
13 KiB
C#
491 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using gehGassi.Domain.Common;
|
|
using gehGassi.Domain.Users;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace gehGassi.Domain.Shop
|
|
{
|
|
/// <summary>
|
|
/// Repräsentiert einen Warenkorb
|
|
/// </summary>
|
|
public class Cart : IAuditable
|
|
{
|
|
/// <summary>
|
|
/// Id des Warenkorbs
|
|
/// </summary>
|
|
[Key]
|
|
[Required]
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Welcher "Kunden-Typ" hat die Bestellung erstellt?
|
|
/// </summary>
|
|
[Required]
|
|
public OrderSource OrderSource { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des App-Users
|
|
/// </summary>
|
|
public string AppUserId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Kunde
|
|
/// </summary>
|
|
public long? CustomerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Total { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal TotalGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Versandkosten Netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Shipment { get; set; }
|
|
|
|
/// <summary>
|
|
/// Versandkosten Brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal ShipmentGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Steuerstufen mit Werten als Json
|
|
/// </summary>
|
|
public string TaxRatesJson { get; set; }
|
|
|
|
/// <summary>
|
|
/// Steuer-Einstellungen
|
|
/// </summary>
|
|
[NotMapped]
|
|
public Dictionary<decimal, decimal> TaxRates
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrWhiteSpace(TaxRatesJson))
|
|
return new Dictionary<decimal, decimal>();
|
|
var taxRates = JsonConvert.DeserializeObject<Dictionary<decimal,decimal>>(TaxRatesJson, new JsonSerializerSettings(){Culture = CultureInfo.CurrentCulture});
|
|
return taxRates;
|
|
}
|
|
set
|
|
{
|
|
var settings = JsonConvert.SerializeObject(value, new JsonSerializerSettings(){Culture = CultureInfo.InvariantCulture });
|
|
TaxRatesJson = settings;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rechnungsland ISO2
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(2)]
|
|
public string BillingCountryCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Lieferland ISO2
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(2)]
|
|
public string DeliveryCountryCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der Erstellung
|
|
/// </summary>
|
|
[Required]
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der letzten Änderung
|
|
/// </summary>
|
|
public DateTimeOffset? LastUpdate { get; set; }
|
|
|
|
#region IAuditable
|
|
/// <summary>
|
|
/// Gibt den eindeutigen Key für die Entität zurück;
|
|
/// Hier als String gelöst, weil damit auch kombinierte Schlüssel möglich sind.
|
|
/// </summary>
|
|
/// <returns>Eindeutiger Key</returns>
|
|
public string AuditKey()
|
|
{
|
|
return Id.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gibt den Objektnamen bzw. die Tabelle der Entität zurück
|
|
/// </summary>
|
|
/// <returns>Objektnamen</returns>
|
|
public string AuditTable()
|
|
{
|
|
return "Carts";
|
|
}
|
|
|
|
public AuditableOptions Options()
|
|
{
|
|
return AuditableOptions.Create | AuditableOptions.Edit | AuditableOptions.Delete;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Repräsentiert einen Warenkorb - Liste
|
|
/// </summary>
|
|
public class CartWithNames
|
|
{
|
|
/// <summary>
|
|
/// Id des Warenkorbs
|
|
/// </summary>
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Welcher "Kunden-Typ" hat die Bestellung erstellt?
|
|
/// </summary>
|
|
public OrderSource OrderSource { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des App-Users
|
|
/// </summary>
|
|
public string AppUserId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Name des App-Users
|
|
/// </summary>
|
|
public string AppUserName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Kunde
|
|
/// </summary>
|
|
public long? CustomerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Name des Kunden
|
|
/// </summary>
|
|
public string CustomerName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Total { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal TotalGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Versandkosten Netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Shipment { get; set; }
|
|
|
|
/// <summary>
|
|
/// Versandkosten Brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal ShipmentGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Steuerstufen mit Werten als Json
|
|
/// </summary>
|
|
public string TaxRatesJson { get; set; }
|
|
|
|
/// <summary>
|
|
/// Steuer-Einstellungen
|
|
/// </summary>
|
|
[NotMapped]
|
|
public Dictionary<decimal, decimal> TaxRates
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrWhiteSpace(TaxRatesJson))
|
|
return new Dictionary<decimal, decimal>();
|
|
var taxRates = JsonConvert.DeserializeObject<Dictionary<decimal, decimal>>(TaxRatesJson, new JsonSerializerSettings() { Culture = CultureInfo.CurrentCulture });
|
|
return taxRates;
|
|
}
|
|
set
|
|
{
|
|
var settings = JsonConvert.SerializeObject(value, new JsonSerializerSettings() { Culture = CultureInfo.InvariantCulture });
|
|
TaxRatesJson = settings;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rechnungsland ISO2
|
|
/// </summary>
|
|
public string BillingCountryCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Lieferland ISO2
|
|
/// </summary>
|
|
public string DeliveryCountryCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der Erstellung
|
|
/// </summary>
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der letzten Änderung
|
|
/// </summary>
|
|
public DateTimeOffset? LastUpdate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Anzahl der Artikel im Warenkorb.
|
|
/// Achtung: Summe der Quantity aller Artikel!
|
|
/// </summary>
|
|
public int ItemCount { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Repräsentiert einen Artikel im Warenkorb
|
|
/// </summary>
|
|
public class CartItem : IAuditable
|
|
{
|
|
/// <summary>
|
|
/// Id des Warenkorb-Items
|
|
/// </summary>
|
|
[Key]
|
|
[Required]
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des Warenkorbs
|
|
/// </summary>
|
|
[Required]
|
|
public long CartId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des Artikels
|
|
/// </summary>
|
|
[Required]
|
|
public int ProductId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Typ
|
|
/// </summary>
|
|
[Required]
|
|
public ProductType ProductType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id einer Listung, Werbung, Banner, Pin im Draft-Mode
|
|
/// </summary>
|
|
[MaxLength(128)]
|
|
public string ItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Stückzahl
|
|
/// </summary>
|
|
[Required]
|
|
public int Quantity { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Price { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal PriceGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes netto für Produkte die 2 Preise benötigen
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Price2 { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes brutto für Produkte die 2 Preise benötigen
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Price2Gross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Netto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal Total { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Brutto
|
|
/// </summary>
|
|
[Required]
|
|
public decimal TotalGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Angewandte Steuer - also z.B. 10%, 20%
|
|
/// </summary>
|
|
[Required]
|
|
public decimal TaxRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Errechneter Steuerbetrag - mit Berücksichtigung der Stückzahl
|
|
/// </summary>
|
|
[Required]
|
|
public decimal TaxRateValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der Erstellung
|
|
/// </summary>
|
|
[Required]
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der letzten Änderung
|
|
/// </summary>
|
|
public DateTimeOffset? LastUpdate { get; set; }
|
|
|
|
#region IAuditable
|
|
/// <summary>
|
|
/// Gibt den eindeutigen Key für die Entität zurück;
|
|
/// Hier als String gelöst, weil damit auch kombinierte Schlüssel möglich sind.
|
|
/// </summary>
|
|
/// <returns>Eindeutiger Key</returns>
|
|
public string AuditKey()
|
|
{
|
|
return Id.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gibt den Objektnamen bzw. die Tabelle der Entität zurück
|
|
/// </summary>
|
|
/// <returns>Objektnamen</returns>
|
|
public string AuditTable()
|
|
{
|
|
return "CartItems";
|
|
}
|
|
|
|
public AuditableOptions Options()
|
|
{
|
|
return AuditableOptions.Create | AuditableOptions.Edit | AuditableOptions.Delete;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Repräsentiert einen Artikel im Warenkorb - Liste
|
|
/// </summary>
|
|
public class CartItemWithNames
|
|
{
|
|
/// <summary>
|
|
/// Id des Warenkorb-Items
|
|
/// </summary>
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des Warenkorbs
|
|
/// </summary>
|
|
public long CartId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id des Artikels
|
|
/// </summary>
|
|
public int ProductId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Name des Produktes
|
|
/// </summary>
|
|
public string ProductName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Artikelnummer des Produktes
|
|
/// </summary>
|
|
public string ProductSku { get; set; }
|
|
|
|
/// <summary>
|
|
/// Bild des Produktes - entweder basierend auf Sprache oder das allgemeine Bild
|
|
/// </summary>
|
|
public string ProductImage { get; set; }
|
|
|
|
/// <summary>
|
|
/// Typ
|
|
/// </summary>
|
|
public ProductType ProductType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Stückzahl
|
|
/// </summary>
|
|
public int Quantity { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes netto
|
|
/// </summary>
|
|
public decimal Price { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes brutto
|
|
/// </summary>
|
|
public decimal PriceGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes netto für Produkte die 2 Preise benötigen
|
|
/// </summary>
|
|
public decimal Price2 { get; set; }
|
|
|
|
/// <summary>
|
|
/// Preis des Produktes brutto für Produkte die 2 Preise benötigen
|
|
/// </summary>
|
|
public decimal Price2Gross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Netto
|
|
/// </summary>
|
|
public decimal Total { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gesamt-Preis Brutto
|
|
/// </summary>
|
|
public decimal TotalGross { get; set; }
|
|
|
|
/// <summary>
|
|
/// Angewandte Steuer - also z.B. 10%, 20%
|
|
/// </summary>
|
|
public decimal TaxRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Errechneter Steuerbetrag - mit Berücksichtigung der Stückzahl
|
|
/// </summary>
|
|
public decimal TaxRateValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Wie viele Produkte müssen mindestens bestellt werden?
|
|
/// </summary>
|
|
public int OrderMinimumQuantity { get; set; }
|
|
|
|
/// <summary>
|
|
/// Wie viele Produkte dürfen maximal bestellt werden?
|
|
/// </summary>
|
|
public int OrderMaximumQuantity { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der Erstellung
|
|
/// </summary>
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// Datum der letzten Änderung
|
|
/// </summary>
|
|
public DateTimeOffset? LastUpdate { get; set; }
|
|
}
|
|
}
|