コード例 #1
0
        public static IEnumerable <VoucherTemplateDto> GetAllVoucherTemplates()
        {
            try
            {
                var vouchers         = (List <tVoucherTemplate>)AccountingDataProvider.GetAllVoucherTemplates();
                var voucherViewModel = new List <VoucherTemplateDto>();
                VoucherTemplateDto model;

                if (vouchers != null)
                {
                    vouchers.ForEach(delegate(tVoucherTemplate voucherTemplate)
                    {
                        model = new VoucherTemplateDto
                        {
                            CompanyId         = voucherTemplate.CompanyId,
                            CompanyName       = "",
                            CreditAccountCode = voucherTemplate.CreditAccount,
                            CreditAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.CreditAccount).AccountName,
                            DebitAccountCode  = voucherTemplate.DebitAccount,
                            DebitAccountName  = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.DebitAccount).AccountName,
                            Narration         = voucherTemplate.Narration,
                            ShortCode         = voucherTemplate.ShortCode,
                        };
                        voucherViewModel.Add(model);
                    }
                                     );

                    return(voucherViewModel);
                }
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            return(null);
        }