Пример #1
0
        public void Save(CategoryDTO dto)
        {
            var category = _categories.Get(dto.CategoryID);

            if (category != null)
            {
                dto.MapTo(category);
                _categories.Update(category);
            }
            else
            {
                category = _categories.Add(dto.MapTo<Category>());
                dto.CategoryID = category.CategoryID;
            }
        }
Пример #2
0
        public void SaveCategoryBudget(Category_BudgetDTO dto)
        {
            var category = new CategoryDTO {
                Account_AccountID = dto.Account_AccountID,
                CategoryID = dto.Category_CategoryID,
                Name = dto.CategoryName,
                Type = CategoryTypeDTO.Expense // TODO: Is this always the case?
            };

            _categoryServices.Save(category);

            dto.Category_CategoryID = category.CategoryID;

            var cb = _categories_budgets.Get(dto.Budget_BudgetID, dto.Category_CategoryID);

            if (cb != null)
            {
                dto.MapTo(cb);
                _categories_budgets.Update(cb);
            }
            else
            {
                cb = _categories_budgets.Add(dto.MapTo<Category_Budget>());
            }
        }