public async Task <IActionResult> Create([FromBody] CreateDepositDto createDepositDto) { var userIdHolder = await _userService.GetUserId(User.Identity.Name); if (userIdHolder.Status == DataHolderStatus.Unauthorized) { return(Unauthorized()); } var createdHolder = await _depositService.CreateDepositAsync(createDepositDto, new Guid(userIdHolder.Data)); if (createdHolder.Status == DataHolderStatus.Failure) { return(BadRequest(createdHolder.Message)); } return(Ok(createdHolder.Data)); }
public async Task <ActionResult> Index(DepositRequestModel model) { var user = await _userService.GetUserByIdAsync(IdentityHelper.CurrentUserId, IdentityHelper.CurrentUserId); if (user != null) { DepositViewModel deposit = new DepositViewModel(); deposit.CreditCardId = model.Deposit.CreditCardId; deposit.Amount = model.Deposit.Amount; var res = await _depositService.CreateDepositAsync(deposit, user); if (res) { return(RedirectToAction("Success", "Response", new { message = "successful" })); } } return(RedirectToAction("Error", "Response", new { message = "Error when process " })); }