public async Task <IActionResult> ExecuteAsync(PublicSavePackageSubscriber publicSavePackageSubscriber, CancellationToken cancellationToken) { var transactionCode = "ABC123XYZ"; var method = "Momo"; var userId = 0; //var transaction = await _packageSubscriberRepository.GetTransactionByTransactionCode(transactionCode, cancellationToken); //if (transaction != null) // return new ConflictResult(); var paidPackage = await _paidPackageRepository.Get(publicSavePackageSubscriber.PaidPackageId, cancellationToken); if (paidPackage == null) { return(new NoContentResult()); } var savePackageSubscriber = new SavePackageSubscriber() { TransactionCode = transactionCode, UserId = userId, PaidPackageId = paidPackage.Id, StartDate = DateTime.Now.ToString("dd/MM/yyyy"), EndDate = publicSavePackageSubscriber.Period == "Y" ? DateTime.Now.AddYears(1).ToString("dd/MM/yyyy") : DateTime.Now.AddMonths(1).ToString("dd/MM/yyyy"), Method = method, Value = publicSavePackageSubscriber.Period == "Y" ? getCurrency(paidPackage, "Y") : getCurrency(paidPackage, "M"), Status = true }; var packageSubscriber = _savePackageSubscriberToPackageSubscriberMapper.Map(savePackageSubscriber); packageSubscriber = await _packageSubscriberRepository.Add(packageSubscriber, cancellationToken); var packageSubscriberViewModel = _packageSubscriberToPackageSubscriberMapper.Map(packageSubscriber); return(new CreatedAtRouteResult( PackageSubscribersControllerRoute.GetPackageSubscriber, new { id = packageSubscriberViewModel.Id }, packageSubscriberViewModel)); }
public Task <IActionResult> PublicPost( [FromServices] IPublicPostPackageSubscriberCommand command, [FromBody] PublicSavePackageSubscriber packageSubscriber, CancellationToken cancellationToken) => command.ExecuteAsync(packageSubscriber);