Skip to content

Commit f783b04

Browse files
committed
refactored code
1 parent 28a2d9f commit f783b04

File tree

13 files changed

+29
-62
lines changed

13 files changed

+29
-62
lines changed

OnionArchitecture/OA.Infrastructure/Extension/ConfigureContainer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.Logging;
23
using OA.Infrastructure.Middleware;
4+
using Serilog;
35

46
namespace OA.Infrastructure.Extension
57
{
@@ -21,5 +23,10 @@ public static void ConfigureSwagger(this IApplicationBuilder app)
2123
});
2224
}
2325

26+
public static void ConfigureSwagger(this ILoggerFactory loggerFactory)
27+
{
28+
loggerFactory.AddSerilog();
29+
}
30+
2431
}
2532
}

OnionArchitecture/OA.Infrastructure/Extension/ConfigureServiceContainer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AutoMapper;
2+
using MediatR;
23
using Microsoft.EntityFrameworkCore;
34
using Microsoft.Extensions.Configuration;
45
using Microsoft.Extensions.DependencyInjection;
@@ -12,7 +13,6 @@
1213
using System;
1314
using System.IO;
1415
using System.Reflection;
15-
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
1616

1717
namespace OA.Infrastructure.Extension
1818
{
@@ -90,5 +90,10 @@ public static void AddController(this IServiceCollection serviceCollection)
9090
serviceCollection.AddControllers().AddNewtonsoftJson();
9191
}
9292

93+
public static void AddMediatorCQRS(this IServiceCollection services)
94+
{
95+
services.AddMediatR(Assembly.GetExecutingAssembly());
96+
}
97+
9398
}
9499
}

OnionArchitecture/OA.Service/DependencyInjection.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

OnionArchitecture/OA.Service/Features/CustomerFeatures/Commands/CreateCustomerCommand.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-

2-
using MediatR;
1+
using MediatR;
32
using OA.Data;
43
using OA.Domain.Entities;
5-
using System;
6-
using System.Collections.Generic;
7-
using System.Text;
84
using System.Threading;
95
using System.Threading.Tasks;
106

@@ -34,7 +30,7 @@ public async Task<int> Handle(CreateCustomerCommand request, CancellationToken c
3430
var customer = new Customer();
3531
customer.CustomerName = request.CustomerName;
3632
customer.ContactName = request.ContactName;
37-
33+
3834
_context.Customers.Add(customer);
3935
await _context.SaveChangesAsync();
4036
return customer.Id;

OnionArchitecture/OA.Service/Features/CustomerFeatures/Commands/DeleteCustomerByIdCommand.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-

2-
using MediatR;
1+
using MediatR;
32
using Microsoft.EntityFrameworkCore;
43
using OA.Data;
5-
using System;
6-
using System.Collections.Generic;
74
using System.Linq;
8-
using System.Text;
95
using System.Threading;
106
using System.Threading.Tasks;
117

OnionArchitecture/OA.Service/Features/CustomerFeatures/Commands/UpdateCustomerCommand.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-

2-
using MediatR;
1+
using MediatR;
32
using OA.Data;
43
using OA.Domain.Entities;
5-
using System;
6-
using System.Collections.Generic;
74
using System.Linq;
8-
using System.Text;
95
using System.Threading;
106
using System.Threading.Tasks;
117

OnionArchitecture/OA.Service/Features/CustomerFeatures/Queries/GetAllCustomerQuery.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-

2-
using MediatR;
1+
using MediatR;
32
using Microsoft.EntityFrameworkCore;
43
using OA.Data;
54
using OA.Domain.Entities;
6-
using System;
75
using System.Collections.Generic;
8-
using System.Text;
96
using System.Threading;
107
using System.Threading.Tasks;
118

OnionArchitecture/OA.Service/Features/CustomerFeatures/Queries/GetCustomerByIdQuery.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-

2-
using MediatR;
1+
using MediatR;
32
using OA.Data;
43
using OA.Domain.Entities;
5-
using System;
6-
using System.Collections.Generic;
74
using System.Linq;
8-
using System.Text;
95
using System.Threading;
106
using System.Threading.Tasks;
117

OnionArchitecture/OA.Test.Unit/Controller/CustomerControllerTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using OA.Domain.Entities;
77
using OA.Infrastructure.ViewModel;
88
using OA.Persistence.Contract;
9-
using OA.Service.Contract;
109
using System.Threading.Tasks;
1110

1211
namespace OA.Test.Unit.Controller

OnionArchitecture/OA.Test.Unit/Service/CustomerServiceTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NUnit.Framework;
33
using OA.Domain.Entities;
44
using OA.Persistence.Contract;
5-
using OA.Service.Implementation;
65

76
namespace OA.Test.Unit.Service
87
{

0 commit comments

Comments
 (0)