예제 #1
0
        public static ExpenseCategoryViewModel Create(ExpenseCategory expenseCategory)
        {
            if (expenseCategory is null)
            {
                throw new ArgumentNullException(nameof(expenseCategory));
            }
            var rv = new ExpenseCategoryViewModel(expenseCategory.ID);

            SetProperties(expenseCategory, rv);
            return(rv);
        }
예제 #2
0
 protected static void SetProperties(ExpenseCategory expenseCategory, ExpenseCategoryViewModel viewModel)
 {
     if (expenseCategory is null)
     {
         throw new ArgumentNullException(nameof(expenseCategory));
     }
     if (viewModel is null)
     {
         throw new ArgumentNullException(nameof(viewModel));
     }
     viewModel.Name               = expenseCategory.Name;
     viewModel.Balance            = expenseCategory.CurrentBalance;
     viewModel.BudgetedAmount     = expenseCategory.BudgetedAmount;
     viewModel.BudgetedPercentage = expenseCategory.BudgetedPercentage;
     viewModel.CategoryName       = expenseCategory.CategoryName ?? string.Empty;
     viewModel.IsHidden           = expenseCategory.IsHidden;
     viewModel.Cap = expenseCategory.Cap;
 }