public static Budget ToBudget(this BudgetModel model) { var moneys = model.Moneys.Select(m => new Money(Amount.Create(m.Amount, Currency.Create(m.Currency)), Category.Create(m.Type), m.Created, new Description(m.Description))).ToImmutableList(); return(new Budget(Month.Create(model.Year, MonthName.Create(model.Month)), Currency.Create(model.Currency), model.CreatedOn, moneys)); }
public (BudgetFile plannedBudgetFile, BudgetFile realBudgetFile) Create(YearOption yearOption, MonthOption monthOption, CurrencyOption currencyOption) { var month = Month.Create(yearOption.Value, MonthName.Create(monthOption.Value)); var currency = Currency.Create(currencyOption.Value); var budget = new Budget(month, currency); var realBudgetFileName = new FileName($"budget-{budget.Month.Year}-{budget.Month.MonthName.Index}"); var plannedBudgetFileName = new FileName($"budget-{budget.Month.Year}-{budget.Month.MonthName.Index}-plan"); return(plannedBudgetFile : new BudgetFile(budget, plannedBudgetFileName), realBudgetFile : new BudgetFile(budget, realBudgetFileName)); }