Пример #1
0
        private AccountDto BuildAccountDto()
        {
            AccountDto dto = new AccountDto()
            {
                AccountKind = AccountTypeOption.GetValue(Account.DEFAULT_ACCOUNT_KIND),
                Description = DescriptionOption.GetValue(String.Empty),
                Name        = AccountName.GetValue(String.Empty),
                Priority    = PriorityOption.GetValue(Account.DEFAULT_PRIORITY)
            };

            if (CategoryNameOption.IsDataValid)
            {
                dto.CategoryId = Repositories.AccountRepository.GetIdByName(CategoryNameOption.GetValue(null));
            }
            else
            {
                dto.CategoryId = null;
            }

            if (AccountId.IsDataValid)
            {
                dto.Id = AccountId.GetValue(-1);
            }
            else
            {
                dto.Id = null;
            }

            return(dto);
        }
Пример #2
0
        public FilterCriteria GetFilterCriteria()
        {
            FilterCriteria criteria = new FilterCriteria();

            //Id
            if (IdOption.IsDataValid)
            {
                criteria.AddField(Account.PROP_ID.DisplayName, $"= {IdOption.GetValue(EMPTY_OPTION)}");
            }

            //Category
            if (CategoryIdOption.IsDataValid)
            {
                Account category = DtoToModelTranslator.FromDto(Repositories.AccountRepository.GetById(CategoryIdOption.GetValue(-1)), DateTime.Today, Repositories);

                criteria.AddField(Account.PROP_CATEGORY.DisplayName, $"= {category.Name}");
            }

            //Description
            if (DescriptionOption.IsDataValid)
            {
                criteria.AddField(Account.PROP_DESCRIPTION.DisplayName, $"contains \"{DescriptionOption.GetValue(EMPTY_OPTION)}\"");
            }

            //Name
            if (NameOption.IsDataValid)
            {
                criteria.AddField(Account.PROP_NAME.DisplayName, $"contains \"{NameOption.GetValue(EMPTY_OPTION)}\"");
            }

            //Priority
            if (PriorityOption.IsDataValid)
            {
                criteria.AddField(Account.PROP_PRIORITY.DisplayName, $"= {PriorityOption.GetValue(EMPTY_OPTION)}");
            }

            //Funds
            if (FundsOption.IsDataValid)
            {
                criteria.AddField(AccountState.PROP_FUNDS.DisplayName, $"= {FundsOption.GetValue(EMPTY_OPTION)}");
            }

            //Account Type
            if (AccountTypeOption.IsDataValid)
            {
                criteria.AddField(Account.PROP_ACCOUNT_KIND.DisplayName, $"= {AccountTypeOption.GetValue(EMPTY_OPTION)}");
            }

            return(criteria);
        }
Пример #3
0
        private List <Account> GetAccounts()
        {
            var dtos = Repositories.AccountRepository.GetAccounts((long?)IdOption.GetValue(null), NameOption.GetValue(null), (long?)CategoryIdOption.GetValue(null), DescriptionOption.GetValue(null), PriorityOption.GetValue(null), (AccountKind?)AccountTypeOption.GetValue(null), FundsOption.GetValue(null), false);

            List <Account> accounts = new List <Account>();

            foreach (var dto in dtos)
            {
                accounts.Add(DtoToModelTranslator.FromDto(dto, DateTime.Today, Repositories));
            }
            return(accounts);
        }