Example #1
0
        public Task <AccountListResponse> GetAccount(AccountListRequest request)
        {
            var response = new AccountListResponse();

            TryCatch(() =>
            {
                var data         = accountService.GetAccounts(request.Keyword, request.Name, request.Type, request.Actives);
                var responseData = data
                                   .Select(m =>
                {
                    var model = AutoMapper.Mapper.Map <Account, AccountView>(m);
                    if (model.Type == (int)AccountTypeConfig.Credit)
                    {
                        model.TypeDisplay = "Ghi nợ";
                    }
                    else if (model.Type == (int)AccountTypeConfig.Debit)
                    {
                        model.TypeDisplay = "Ghi có";
                    }
                    else if (model.Type == (int)AccountTypeConfig.Duality)
                    {
                        model.TypeDisplay = "Lưỡng tính";
                    }
                    else if (model.Type == (int)AccountTypeConfig.Nobalance)
                    {
                        model.TypeDisplay = "Không có số dư";
                    }
                    else
                    {
                        model.TypeDisplay = "";
                    }

                    var lstChildrenAccount = GetListParentAccountView(model.Id);
                    model.subChildren      = lstChildrenAccount;

                    return(model);
                })
                                   .ToList();

                response.SetData(responseData).Successful();
            }, response);
            return(Task.FromResult(response));
        }