public async Task <LedgerFinancialYearBalanceModel> GetLedgerFinancialYearBalanceById(int ledgerFinancialYearBalanceId)
        {
            LedgerFinancialYearBalanceModel ledgerFinancialYearBalanceModel = null;

            IList <LedgerFinancialYearBalanceModel> ledgerFinancialYearBalanceModelList = await GetLedgerFinancialYearBalanceList(ledgerFinancialYearBalanceId);

            if (null != ledgerFinancialYearBalanceModelList && ledgerFinancialYearBalanceModelList.Any())
            {
                ledgerFinancialYearBalanceModel = ledgerFinancialYearBalanceModelList.FirstOrDefault();
            }

            return(ledgerFinancialYearBalanceModel); // returns.
        }
        public async Task <bool> UpdateLedgerFinancialYearBalance(LedgerFinancialYearBalanceModel ledgerFinancialYearBalanceModel)
        {
            bool isUpdated = false;

            // get record.
            Ledgerfinancialyearbalance ledgerFinancialYearBalance = await GetByIdAsync(w => w.LedgerBalanceId == ledgerFinancialYearBalanceModel.LedgerBalanceId);

            if (null != ledgerFinancialYearBalance)
            {
                // assign values.
                ledgerFinancialYearBalance.CurrencyId             = ledgerFinancialYearBalanceModel.CurrencyId;
                ledgerFinancialYearBalance.ExchangeRate           = ledgerFinancialYearBalanceModel.ExchangeRate;
                ledgerFinancialYearBalance.OpeningBalanceAmountFc = ledgerFinancialYearBalanceModel.OpeningBalanceAmountFc;
                ledgerFinancialYearBalance.OpeningBalanceAmount   = ledgerFinancialYearBalanceModel.OpeningBalanceAmount;
                isUpdated = await Update(ledgerFinancialYearBalance);
            }

            return(isUpdated); // returns.
        }
        public async Task <int> CreateLedgerFinancialYearBalance(LedgerFinancialYearBalanceModel ledgerFinancialYearBalanceModel)
        {
            int ledgerFinancialYearBalanceId = 0;

            // assign values.
            Ledgerfinancialyearbalance ledgerFinancialYearBalance = new Ledgerfinancialyearbalance();

            ledgerFinancialYearBalance.LedgerId               = ledgerFinancialYearBalanceModel.LedgerId;
            ledgerFinancialYearBalance.FinancialYearId        = ledgerFinancialYearBalanceModel.FinancialYearId;
            ledgerFinancialYearBalance.CompanyId              = ledgerFinancialYearBalanceModel.CompanyId;
            ledgerFinancialYearBalance.CurrencyId             = ledgerFinancialYearBalanceModel.CurrencyId;
            ledgerFinancialYearBalance.ExchangeRate           = ledgerFinancialYearBalanceModel.ExchangeRate;
            ledgerFinancialYearBalance.OpeningBalanceAmountFc = ledgerFinancialYearBalanceModel.OpeningBalanceAmountFc;
            ledgerFinancialYearBalance.OpeningBalanceAmount   = ledgerFinancialYearBalanceModel.OpeningBalanceAmount;
            await Create(ledgerFinancialYearBalance);

            ledgerFinancialYearBalanceId = ledgerFinancialYearBalance.LedgerBalanceId;

            return(ledgerFinancialYearBalanceId); // returns.
        }
        private async Task <LedgerFinancialYearBalanceModel> AssignValueToModel(Ledgerfinancialyearbalance ledgerFinancialYearBalance)
        {
            return(await Task.Run(() =>
            {
                LedgerFinancialYearBalanceModel ledgerFinancialYearBalanceModel = new LedgerFinancialYearBalanceModel();
                ledgerFinancialYearBalanceModel.LedgerBalanceId = ledgerFinancialYearBalance.LedgerBalanceId;
                ledgerFinancialYearBalanceModel.LedgerId = ledgerFinancialYearBalance.LedgerId;
                ledgerFinancialYearBalanceModel.FinancialYearId = ledgerFinancialYearBalance.FinancialYearId;
                ledgerFinancialYearBalanceModel.CompanyId = ledgerFinancialYearBalance.CompanyId;
                ledgerFinancialYearBalanceModel.CurrencyId = ledgerFinancialYearBalance.CurrencyId;
                ledgerFinancialYearBalanceModel.ExchangeRate = ledgerFinancialYearBalance.ExchangeRate;
                ledgerFinancialYearBalanceModel.OpeningBalanceAmountFc = ledgerFinancialYearBalance.OpeningBalanceAmountFc;
                ledgerFinancialYearBalanceModel.OpeningBalanceAmount = ledgerFinancialYearBalance.OpeningBalanceAmount;

                //#####
                ledgerFinancialYearBalanceModel.LedgerName = ledgerFinancialYearBalance.Ledger.LedgerName;
                ledgerFinancialYearBalanceModel.FinancialYearName = ledgerFinancialYearBalance.FinancialYear.FinancialYearName;
                ledgerFinancialYearBalanceModel.CompanyName = ledgerFinancialYearBalance.Company.CompanyName;
                ledgerFinancialYearBalanceModel.CurrencyName = ledgerFinancialYearBalance.Currency.CurrencyName;
                ledgerFinancialYearBalanceModel.PreparedByName = ledgerFinancialYearBalance.PreparedByUser.UserName;

                return ledgerFinancialYearBalanceModel;
            }));
        }