Example #1
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);
        }
Example #2
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);
        }