public async Task <bool> UpdateExpenseRuleAsync(ExpenseRule expRule, int id)
        {
            bool vResult = false;
            var  entiry  = _ctx.ExpenseRules.FirstOrDefault(x => x.Id == id);

            try
            {
                if (entiry != null)
                {
                    entiry.RuleName          = expRule.RuleName;
                    entiry.SearchText        = expRule.SearchText;
                    entiry.IsActiveRule      = expRule.IsActiveRule;
                    entiry.Priority          = expRule.Priority;
                    entiry.ExpenseCategoryId = expRule.ExpenseCategoryId;
                    entiry.CurrencyId        = expRule.CurrencyId;
                    entiry.PaymentMethod     = expRule.PaymentMethod;
                    entiry.PaymentType       = expRule.PaymentType;
                    entiry.updateDate        = DateTime.UtcNow;
                    _ctx.Entry(entiry).State = EntityState.Modified;
                    await _ctx.SaveChangesAsync();

                    vResult = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(vResult);
        }
        public async Task <ExpenseRule> FindExpenseAsync(string tofind)
        {
            var expRule = new ExpenseRule();

            expRule = await _ctx.ExpenseRules
                      .Where(f => expRule.SearchText.Contains(tofind)).FirstOrDefaultAsync();

            return(expRule);
        }
        public async Task <int> NewExpenseRuleAsync(ExpenseRule expRule)
        {
            var result = -1;

            try
            {
                _ctx.Add(expRule);
                result = await _ctx.SaveChangesAsync();

                if (result < 1)
                {
                    throw new Exception("Error occurred while adding new expense rule into database");
                }
                result = expRule.Id;
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }