Browse Source

Added initial IPaymentRequestAppService

pull/69/head
Halil İbrahim Kalkan 5 years ago
parent
commit
45d2e940eb
  1. 10
      modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs
  2. 17
      modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs
  3. 18
      modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestDto.cs
  4. 5
      modules/payment/src/Payment.Application/PaymentApplicationAutoMapperProfile.cs
  5. 29
      modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs
  6. 10
      modules/payment/src/Payment.Domain/PaymentRequests/IPaymentRequestRepository.cs
  7. 8
      modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs
  8. 15
      modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/Repositories/PaymentRequestRepository.cs

10
modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs

@ -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);
}
}

17
modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs

@ -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; }
}
}

18
modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestDto.cs

@ -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; }
}
}

5
modules/payment/src/Payment.Application/PaymentApplicationAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper;
using Payment.PaymentRequests;
namespace Payment
{
@ -6,9 +7,7 @@ namespace Payment
{
public PaymentApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<PaymentRequest, PaymentRequestDto>();
}
}
}

29
modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs

@ -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);
}
}
}

10
modules/payment/src/Payment.Domain/PaymentRequests/IPaymentRequestRepository.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Domain.Repositories;
namespace Payment.PaymentRequests
{
public interface IPaymentRequestRepository : IRepository<PaymentRequest, Guid>
{
}
}

8
modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs

@ -7,8 +7,10 @@ namespace Payment.PaymentRequests
{
public class PaymentRequest : CreationAuditedAggregateRoot<Guid>
{
[CanBeNull]
public string CustomerId { get; private set; }
[CanBeNull]
public string ProductId { get; private set; }
[NotNull]
@ -20,13 +22,15 @@ namespace Payment.PaymentRequests
public PaymentRequest(
Guid id,
[NotNull] string productName,
[CanBeNull] string customerId,
[CanBeNull] string productId,
[NotNull] string productName,
decimal amount)
: base(id)
{
ProductName = Check.NotNullOrWhiteSpace(productName, nameof(productName));
CustomerId = customerId;
ProductId = productId;
ProductName = Check.NotNullOrWhiteSpace(productName, nameof(productName));
Amount = amount;
}
}

15
modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/Repositories/PaymentRequestRepository.cs

@ -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…
Cancel
Save