diff --git a/H_PLUS_Sports/H_PLUS_Sports.csproj b/H_PLUS_Sports/H_PLUS_Sports.csproj index 9da7105..9ca2b68 100644 --- a/H_PLUS_Sports/H_PLUS_Sports.csproj +++ b/H_PLUS_Sports/H_PLUS_Sports.csproj @@ -5,6 +5,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/H_PLUS_Sports/Repositories/OrderRepository.cs b/H_PLUS_Sports/Repositories/OrderRepository.cs index 8b131c4..a401501 100644 --- a/H_PLUS_Sports/Repositories/OrderRepository.cs +++ b/H_PLUS_Sports/Repositories/OrderRepository.cs @@ -24,33 +24,33 @@ namespace H_Plus_Sports.Repositories public async Task Add(Order order) { await _context.Order.AddAsync(order); - await _context.SaveChangesAsync(); + await _context.SaveChangesAsync().ConfigureAwait(true); return order; } public async Task Find(int id) { - return await _context.Order.Include(order => order.OrderItem).Include(order => order.Customer).SingleOrDefaultAsync(a => a.OrderId == id); + return await _context.Order.Include(order => order.OrderItem).Include(order => order.Customer).SingleOrDefaultAsync(a => a.OrderId == id).ConfigureAwait(true); } public async Task Remove(int id) { var order = _context.Order.Single(a => a.OrderId == id); _context.Order.Remove(order); - await _context.SaveChangesAsync(); + await _context.SaveChangesAsync().ConfigureAwait(true); return order; } public async Task Update(Order order) { _context.Order.Update(order); - await _context.SaveChangesAsync(); + await _context.SaveChangesAsync().ConfigureAwait(true); return order; } public async Task Exists(int id) { - return await _context.Order.AnyAsync(e => e.OrderId == id); + return await _context.Order.AnyAsync(e => e.OrderId == id).ConfigureAwait(true); } } } \ No newline at end of file diff --git a/H_PLUS_Sports/Startup.cs b/H_PLUS_Sports/Startup.cs index edd36fa..67ea22b 100644 --- a/H_PLUS_Sports/Startup.cs +++ b/H_PLUS_Sports/Startup.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; namespace H_Plus_Sports { @@ -35,7 +36,10 @@ namespace H_Plus_Sports services.AddScoped(); services.AddScoped(); - services.AddMvc(); + services.AddMvc(option => option.EnableEndpointRouting = false) + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) + .AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); + services.AddControllers(); var connection = "Server=tcp:hsportsoeman.database.windows.net,1433;Initial Catalog=H_Plus_Sports;Persist Security Info=False;User ID=saTfoman;Password=Jes@lin78;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; services.AddDbContext(options => options.UseSqlServer(connection)); diff --git a/H_Plus_Sports.Tests/CustomerIntegrationTests.cs b/H_Plus_Sports.Tests/CustomerIntegrationTests.cs index b1c39b9..a753f5b 100644 --- a/H_Plus_Sports.Tests/CustomerIntegrationTests.cs +++ b/H_Plus_Sports.Tests/CustomerIntegrationTests.cs @@ -1,11 +1,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; using System.Net; using System.Net.Http; -using System.Text; namespace H_Plus_Sports.Tests { diff --git a/H_Plus_Sports.Tests/OrderIntegrationTests.cs b/H_Plus_Sports.Tests/OrderIntegrationTests.cs index f7509f6..3d02c73 100644 --- a/H_Plus_Sports.Tests/OrderIntegrationTests.cs +++ b/H_Plus_Sports.Tests/OrderIntegrationTests.cs @@ -1,8 +1,8 @@ -using System.Net; -using System.Net.Http; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Net; +using System.Net.Http; namespace H_Plus_Sports.Tests { [TestClass]