Example #1
0
            public async Task <List <GetAllWalletsDto> > Handle(GetAllWalletsQuery request, CancellationToken cancellationToken)
            {
                var wallets = mapper.Map <List <GetAllWalletsDto> >(await context.Wallets.ToListAsync());

                foreach (var wallet in wallets)
                {
                    var rider = await context.Riders.FindAsync(wallet.RiderId);

                    if (rider != null)
                    {
                        wallet.RiderName = $"{ rider.LastName }, { rider.FirstName }";
                    }

                    var walletStatus = await context.WalletStatus.FindAsync(wallet.WalletStatusId);

                    if (walletStatus != null)
                    {
                        wallet.Status = walletStatus.Status;
                    }

                    if (wallet.DateUpdated == null)
                    {
                        wallet.DateUpdatedFormatted = string.Empty;
                    }
                    else
                    {
                        wallet.DateUpdatedFormatted = wallet.DateUpdated.GetValueOrDefault().ToString("MM/dd/yyyy");
                    }

                    wallet.DateCreatedFormatted = wallet.DateCreated.ToString("MM/dd/yyyy");
                }

                return(wallets);
            }
        public async Task <IActionResult> GetAllWallets([FromQuery] WalletsParameter walletsParameter)
        {
            var getAllWalletsQuery = new GetAllWalletsQuery(walletsParameter);

            var result = await mediator.Send(getAllWalletsQuery);

            return(StatusCode((int)result.Code, result.Value));
        }
        public async Task <IActionResult> GetWaallets([FromQuery] WalletsParameter walletsParameter)
        {
            var getAllWalletsQuery = new GetAllWalletsQuery(walletsParameter);
            var result             = await mediator.Send(getAllWalletsQuery);

            if (result.Code == HttpStatusCode.OK)
            {
                Response.Headers.Add("X-Pagination", PagedList <Entity> .ToJson(result.Value as PagedList <Entity>));
            }

            return(StatusCode((int)result.Code, result.Value));
        }