Created
January 14, 2021 09:33
-
-
Save tatarincev/5f9f7efe797a389f084b4cfbcb515a64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Module : IModule | |
{ | |
public void Initialize(IServiceCollection serviceCollection) | |
{ | |
//register CustomerOrderService in DI first | |
serviceCollection.AddTransient<CustomerOrderService>(); | |
//Register decorator for original CustomerOrderService | |
serviceCollection.AddTransient<ICustomerOrderService>(provider => new MyCoolCustomerOrderService(provider.GetRequiredService<CustomerOrderService>())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Threading.Tasks; | |
using VirtoCommerce.OrdersModule.Core.Model; | |
using VirtoCommerce.OrdersModule.Core.Services; | |
namespace VirtoCommerce.OrdersModule.Data.Services | |
{ | |
public class MyCoolCustomerOrderService : ICustomerOrderService | |
{ | |
private readonly ICustomerOrderService _originalService; | |
public MyCoolCustomerOrderService(ICustomerOrderService originalService) | |
{ | |
_originalService = originalService; | |
} | |
public Task DeleteAsync(string[] ids) | |
{ | |
return _originalService.DeleteAsync(ids); | |
} | |
public Task<CustomerOrder> GetByIdAsync(string orderId, string responseGroup = null) | |
{ | |
return _originalService.GetByIdAsync(orderId, responseGroup); | |
} | |
public Task<CustomerOrder[]> GetByIdsAsync(string[] orderIds, string responseGroup = null) | |
{ | |
return _originalService.GetByIdsAsync(orderIds, responseGroup); | |
} | |
public Task SaveChangesAsync(CustomerOrder[] orders) | |
{ | |
//TODO: Add validation logic here | |
return _originalService.SaveChangesAsync(orders); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment