示例#1
0
        public async Task <IActionResult> TransactionAgencySearch(int walletid, TransactionType?SearchType, DateTime?StartDate, DateTime?EndDate, int pageindex = 1)
        {
            ViewBag.SearchTypes = new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>
            {
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = "Tất cả", Value = ""
                },
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = TransactionType.WalletRecharge.ToName(), Value = ((int)TransactionType.WalletRecharge).ToString()
                },
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = TransactionType.CampaignServiceCharge.ToName(), Value = ((int)TransactionType.CampaignServiceCharge).ToString()
                },
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = TransactionType.CampaignServiceCashBack.ToName(), Value = ((int)TransactionType.CampaignServiceCashBack).ToString()
                },
            };

            ListTransactionViewModel list = null;

            list = await _ITransactionBusiness.GetTransactionsByType(SearchType, walletid, walletid, StartDate, EndDate, pageindex, 25);

            list.TransactionType = SearchType;

            var wallet = _IWalletRepository.GetById(walletid);

            if (wallet != null)
            {
                ViewBag.Wallet = wallet;
                if (wallet.EntityType == Core.Entities.EntityType.Account)
                {
                    var account = _IAccountBusiness.GetAccount(wallet.EntityId);
                    if (account.Result != null)
                    {
                        ViewBag.Account = account.Result;
                    }
                }
                if (wallet.EntityType == Core.Entities.EntityType.Agency)
                {
                    var agency = _IAgencyBusiness.GetAgency(wallet.EntityId);
                    if (agency.Result != null)
                    {
                        ViewBag.Account = agency.Result;
                    }
                }
            }


            if (list == null)
            {
                TempData["MessageError"] = "Don't have transaction!";
            }

            return(View(list));
        }
示例#2
0
        public async Task <IActionResult> TransactionSearch(int walletid, string SearchType, DateTime?StartDate, DateTime?EndDate, int pageindex = 1)
        {
            ViewBag.SearchTypes = new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>
            {
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = "Tất cả", Value = ""
                },
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = "Cộng tiền", Value = "CongTien"
                },
                new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = "Trừ tiền", Value = "TruTien"
                },
            };

            ListTransactionViewModel list = null;

            list = await _ITransactionBusiness.GetTransactions(SearchType, walletid, walletid, StartDate, EndDate, pageindex, 25);

            list.SearchType = SearchType;

            var wallet = _IWalletRepository.GetById(walletid);

            if (wallet != null)
            {
                ViewBag.Wallet = wallet;
                if (wallet.EntityType == Core.Entities.EntityType.Account)
                {
                    var account = _IAccountBusiness.GetAccount(wallet.EntityId);
                    if (account.Result != null)
                    {
                        ViewBag.Account = account.Result;
                    }
                }
                if (wallet.EntityType == Core.Entities.EntityType.Agency)
                {
                    var agency = _IAgencyBusiness.GetAgency(wallet.EntityId);
                    if (agency.Result != null)
                    {
                        ViewBag.Account = agency.Result;
                    }
                }
            }


            if (list == null)
            {
                TempData["MessageError"] = "Don't have transaction!";
            }

            return(View(list));
        }
        public async Task<ListTransactionViewModel> FillTransactions(TransactionType type, TransactionStatus status, int pageindex)
        {
            var _listTransactionViewModel = new ListTransactionViewModel();

            if (status == TransactionStatus.All)
            {
                _listTransactionViewModel = await _ITransactionBussiness.GetTransactionByType(type, pageindex, 20);
            }
            else
            {
                _listTransactionViewModel = await _ITransactionBussiness.GetTransactions(type, status, pageindex, 20);
            }


            foreach(var item in _listTransactionViewModel.Transactions)
            {
                try {
                    if(item.SenderId == 1)
                    {
                        item.SenderName = "System";
                    }
                    else
                    {
                        var wallet = _IWalletBusiness.Get(item.SenderId);
                        item.SenderName = wallet.Name;
                        item.Wallet = wallet;
                    }
                    
                }
                catch { } 

                try {
                    var wallet = _IWalletBusiness.Get(item.ReceiverId);
                    item.ReceiverName = wallet.Name;
                    item.WalletReceiver = wallet;
                }
                catch { }
            }


            return _listTransactionViewModel;
        }