} // For EF private Expense(Guid id, string name, string description, Money amount, DateTime expenseTime, Supplier supplier, Category category, ConstructionStage constructionStage) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); } if (string.IsNullOrWhiteSpace(description)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(description)); } Id = id; Name = name; Description = description; Amount = amount ?? throw new ArgumentNullException(nameof(amount)); ExpenseTime = expenseTime; Supplier = supplier; ConstructionStage = constructionStage ?? throw new ArgumentNullException(nameof(constructionStage)); Category = category ?? throw new ArgumentNullException(nameof(category)); CategoryId = category.Id; SupplierId = supplier?.Id; ConstructionStageId = constructionStage.Id; }
public static Expense New(string name, string description, Money amount, DateTime expenseTime, Supplier supplier, Category category, ConstructionStage constructionStage) { return(new Expense(Guid.NewGuid(), name, description, amount, expenseTime, supplier, category, constructionStage)); }