public IActionResult GenerateTopup(GenerateTopupCommand command)
        {
            if (int.Parse(command.Account.Substring(0, 2)) != (int)EW_Enumerations.EW_UserTypeEnum.Admin)
            {
                return(BadRequest());
            }

            bool isExist = _userService.ExistAccountNo(command.Account);

            if (!isExist)
            {
                return(BadRequest());
            }

            TopupResultDTO result = _transactionService.GenerateTopUp(command.Account, command.Amount);

            if (result == null)
            {
                return(BadRequest());
            }

            GenerateTopupViewModel viewModel = new GenerateTopupViewModel()
            {
                ReferenceNumber = result.ReferenceNumber,
                ExpireDate      = result.ExpireDate
            };

            return(Ok(viewModel));
        }
Example #2
0
        public async Task <ResultServiceModel <GenerateTopupViewModel> > GenerateTopup(string account, decimal amount)
        {
            GenerateTopupCommand model = new GenerateTopupCommand()
            {
                Account = account,
                Amount  = amount
            };

            string url = serviceUrl + "GenerateTopup";

            return(await Post <GenerateTopupViewModel>(url, model));
        }