mirror of https://github.com/abpframework/eventhub
8 changed files with 107 additions and 5 deletions
@ -0,0 +1,10 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Payment.PaymentRequests |
|||
{ |
|||
public interface IPaymentRequestAppService : IApplicationService |
|||
{ |
|||
Task<PaymentRequestDto> CreateAsync(PaymentRequestCreationDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace Payment.PaymentRequests |
|||
{ |
|||
public class PaymentRequestCreationDto : ExtensibleObject |
|||
{ |
|||
public string CustomerId { get; set; } |
|||
|
|||
public string ProductId { get; set; } |
|||
|
|||
[Required] |
|||
public string ProductName { get; set; } |
|||
|
|||
public decimal Amount { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Payment.PaymentRequests |
|||
{ |
|||
public class PaymentRequestDto : CreationAuditedEntityDto<Guid> |
|||
{ |
|||
public string CustomerId { get; set; } |
|||
|
|||
public string ProductId { get; set; } |
|||
|
|||
public string ProductName { get; set; } |
|||
|
|||
public decimal Amount { get; set; } |
|||
|
|||
public PaymentRequestState State { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Payment.PaymentRequests |
|||
{ |
|||
public class PaymentRequestAppService : PaymentAppService, IPaymentRequestAppService |
|||
{ |
|||
private readonly IPaymentRequestRepository _paymentRequestRepository; |
|||
|
|||
public PaymentRequestAppService(IPaymentRequestRepository paymentRequestRepository) |
|||
{ |
|||
_paymentRequestRepository = paymentRequestRepository; |
|||
} |
|||
|
|||
public async Task<PaymentRequestDto> CreateAsync(PaymentRequestCreationDto input) |
|||
{ |
|||
var paymentRequest = new PaymentRequest( |
|||
GuidGenerator.Create(), |
|||
input.CustomerId, |
|||
input.ProductId, |
|||
input.ProductName, |
|||
input.Amount |
|||
); |
|||
|
|||
await _paymentRequestRepository.InsertAsync(paymentRequest); |
|||
|
|||
return ObjectMapper.Map<PaymentRequest, PaymentRequestDto>(paymentRequest); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Payment.PaymentRequests |
|||
{ |
|||
public interface IPaymentRequestRepository : IRepository<PaymentRequest, Guid> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using Payment.PaymentRequests; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace Payment.EntityFrameworkCore.Repositories |
|||
{ |
|||
public class PaymentRequestRepository : EfCoreRepository<IPaymentDbContext, PaymentRequest,Guid>, IPaymentRequestRepository |
|||
{ |
|||
public PaymentRequestRepository(IDbContextProvider<IPaymentDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue