Skip to content

Commit

Permalink
Updated all projects to Dotnet7
Browse files Browse the repository at this point in the history
  • Loading branch information
yashints committed Sep 7, 2023
1 parent 236553d commit d88293a
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 105 deletions.
11 changes: 6 additions & 5 deletions src/ApplicationCore/ApplicationCore.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.ApplicationCore</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" Version="4.0.1" />
<PackageReference Include="Ardalis.Specification" Version="6.1.0" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="Ardalis.GuardClauses" Version="4.1.1" />
<PackageReference Include="Ardalis.Specification" Version="7.0.0" />
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/ApplicationCore/Services/BasketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public BasketService(IRepository<Basket> basketRepository,
public async Task<Basket> AddItemToBasket(string username, int catalogItemId, decimal price, int quantity = 1)
{
var basketSpec = new BasketWithItemsSpecification(username);
var basket = await _basketRepository.GetBySpecAsync(basketSpec);
var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec);

if (basket == null)
{
Expand All @@ -46,7 +46,7 @@ public async Task<Basket> SetQuantities(int basketId, Dictionary<string, int> qu
{
Guard.Against.Null(quantities, nameof(quantities));
var basketSpec = new BasketWithItemsSpecification(basketId);
var basket = await _basketRepository.GetBySpecAsync(basketSpec);
var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec);
Guard.Against.NullBasket(basketId, basket);

foreach (var item in basket.Items)
Expand All @@ -67,10 +67,10 @@ public async Task TransferBasketAsync(string anonymousId, string userName)
Guard.Against.NullOrEmpty(anonymousId, nameof(anonymousId));
Guard.Against.NullOrEmpty(userName, nameof(userName));
var anonymousBasketSpec = new BasketWithItemsSpecification(anonymousId);
var anonymousBasket = await _basketRepository.GetBySpecAsync(anonymousBasketSpec);
var anonymousBasket = await _basketRepository.FirstOrDefaultAsync(anonymousBasketSpec);
if (anonymousBasket == null) return;
var userBasketSpec = new BasketWithItemsSpecification(userName);
var userBasket = await _basketRepository.GetBySpecAsync(userBasketSpec);
var userBasket = await _basketRepository.FirstOrDefaultAsync(userBasketSpec);
if (userBasket == null)
{
userBasket = new Basket(userName);
Expand Down
2 changes: 1 addition & 1 deletion src/ApplicationCore/Services/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public OrderService(IRepository<Basket> basketRepository,
public async Task CreateOrderAsync(int basketId, Address shippingAddress)
{
var basketSpec = new BasketWithItemsSpecification(basketId);
var basket = await _basketRepository.GetBySpecAsync(basketSpec);
var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec);

Guard.Against.NullBasket(basketId, basket);
Guard.Against.EmptyBasketOnCheckout(basket.Items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.eShopWeb.ApplicationCore.Specifications;

public sealed class BasketWithItemsSpecification : Specification<Basket>, ISingleResultSpecification
public sealed class BasketWithItemsSpecification : Specification<Basket>, ISingleResultSpecification<Basket>
{
public BasketWithItemsSpecification(int basketId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.eShopWeb.ApplicationCore.Specifications;

public class OrderWithItemsByIdSpec : Specification<Order>, ISingleResultSpecification
public class OrderWithItemsByIdSpec : Specification<Order>, ISingleResultSpecification<Order>
{
public OrderWithItemsByIdSpec(int orderId)
{
Expand Down
19 changes: 10 additions & 9 deletions src/BlazorAdmin/BlazorAdmin.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
<PackageReference Include="BlazorInputFile" Version="0.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.10" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorAdmin/Pages/CatalogItemPage/Delete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@

@code {
[Parameter]
public IEnumerable<CatalogBrand> Brands { get; set; }
public IEnumerable<CatalogBrand> Brands { get; set; } = default!;
[Parameter]
public IEnumerable<CatalogType> Types { get; set; }
public IEnumerable<CatalogType> Types { get; set; } = default!;

[Parameter]
public EventCallback<string> OnSaveClick { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorAdmin/Pages/CatalogItemPage/Details.razor
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@

@code {
[Parameter]
public IEnumerable<CatalogBrand> Brands { get; set; }
public IEnumerable<CatalogBrand> Brands { get; set; } = default!;
[Parameter]
public IEnumerable<CatalogType> Types { get; set; }
public IEnumerable<CatalogType> Types { get; set; } = default!;

[Parameter]
public EventCallback<int> OnEditClick { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions src/BlazorShared/BlazorShared.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>BlazorShared</RootNamespace>
<AssemblyName>BlazorShared</AssemblyName>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorInputFile" Version="0.2.0" />
<PackageReference Include="FluentValidation" Version="11.2.1" />
<PackageReference Include="FluentValidation" Version="11.7.1" />
</ItemGroup>

</Project>
13 changes: 7 additions & 6 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.Infrastructure</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="6.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.7" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.22.1" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" />
Expand Down
8 changes: 2 additions & 6 deletions src/PublicApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

builder.Services.AddControllers();

builder.Services.AddMediatR(typeof(CatalogItem).Assembly);
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(CatalogItem).Assembly));
builder.Services.AddAutoMapper(typeof(MappingProfile).Assembly);

builder.Services.AddEndpointsApiExplorer();
Expand Down Expand Up @@ -174,11 +174,7 @@
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});

app.MapControllers();
app.MapEndpoints();
app.Logger.LogInformation("LAUNCHING PublicApi");
app.Run();
Expand Down
38 changes: 19 additions & 19 deletions src/PublicApi/PublicApi.csproj
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.PublicApi</RootNamespace>
<UserSecretsId>5b662463-1efd-4bae-bde4-befe0be3e8ff</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="4.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
<PackageReference Include="MinimalApi.Endpoint" Version="1.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.7">
<PackageReference Include="Ardalis.ApiEndpoints" Version="4.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="MinimalApi.Endpoint" Version="1.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.16.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.7" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.9" />

<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.22.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.3" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Web/Areas/Identity/Pages/Account/Login.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class InputModel
public bool RememberMe { get; set; }
}

public async Task OnGetAsync(string? returnUrl = null)
public async Task OnGetAsync(string returnUrl = null)
{
if (!string.IsNullOrEmpty(ErrorMessage))
{
Expand All @@ -64,7 +64,7 @@ public async Task OnGetAsync(string? returnUrl = null)
ReturnUrl = returnUrl;
}

public async Task<IActionResult> OnPostAsync(string? returnUrl = null)
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
returnUrl = returnUrl ?? Url.Content("~/");

Expand Down
4 changes: 1 addition & 3 deletions src/Web/Configuration/ConfigureWebServices.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using MediatR;
using Microsoft.eShopWeb.Web.Interfaces;
using Microsoft.eShopWeb.Web.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.eShopWeb.Web.Configuration;

public static class ConfigureWebServices
{
public static IServiceCollection AddWebServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddMediatR(typeof(BasketViewModelService).Assembly);
services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(BasketViewModelService).Assembly));
services.AddScoped<IBasketViewModelService, BasketViewModelService>();
services.AddScoped<CatalogViewModelService>();
services.AddScoped<ICatalogItemViewModelService, CatalogItemViewModelService>();
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Features/OrderDetails/GetOrderDetailsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<OrderViewModel> Handle(GetOrderDetails request,
CancellationToken cancellationToken)
{
var spec = new OrderWithItemsByIdSpec(request.OrderId);
var order = await _orderRepository.GetBySpecAsync(spec, cancellationToken);
var order = await _orderRepository.FirstOrDefaultAsync(spec, cancellationToken);

if (order == null)
{
Expand Down
5 changes: 2 additions & 3 deletions src/Web/Pages/Basket/BasketItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ public class BasketItemViewModel
{
public int Id { get; set; }
public int CatalogItemId { get; set; }
public string? ProductName { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal OldUnitPrice { get; set; }

[Range(0, int.MaxValue, ErrorMessage = "Quantity must be bigger than 0")]
public int Quantity { get; set; }

public string? PictureUrl { get; set; }
public string PictureUrl { get; set; }
}
16 changes: 7 additions & 9 deletions src/Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,13 @@
app.UseAuthentication();
app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("default", "{controller:slugify=Home}/{action:slugify=Index}/{id?}");
endpoints.MapRazorPages();
endpoints.MapHealthChecks("home_page_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("homePageHealthCheck") });
endpoints.MapHealthChecks("api_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("apiHealthCheck") });
//endpoints.MapBlazorHub("/admin");
endpoints.MapFallbackToFile("index.html");
});

app.MapControllerRoute("default", "{controller:slugify=Home}/{action:slugify=Index}/{id?}");
app.MapRazorPages();
app.MapHealthChecks("home_page_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("homePageHealthCheck") });
app.MapHealthChecks("api_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("apiHealthCheck") });
//endpoints.MapBlazorHub("/admin");
app.MapFallbackToFile("index.html");

app.Logger.LogInformation("LAUNCHING");
app.Run();
2 changes: 1 addition & 1 deletion src/Web/Services/BasketViewModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BasketViewModelService(IRepository<Basket> basketRepository,
public async Task<BasketViewModel> GetOrCreateBasketForUser(string userName)
{
var basketSpec = new BasketWithItemsSpecification(userName);
var basket = (await _basketRepository.GetBySpecAsync(basketSpec));
var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec);

if (basket == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Web/ViewModels/Manage/IndexViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Microsoft.eShopWeb.Web.ViewModels.Manage;

public class IndexViewModel
{
public string? Username { get; set; }
public string Username { get; set; }

public bool IsEmailConfirmed { get; set; }

Expand All @@ -16,5 +16,5 @@ public class IndexViewModel
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }

public string? StatusMessage { get; set; }
public string StatusMessage { get; set; }
}
2 changes: 1 addition & 1 deletion src/Web/Views/Shared/_LoginPartial.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if (Context.User.Identity.IsAuthenticated)
@if (Context.User.Identity != null && Context.User.Identity.IsAuthenticated)
{
<section class="col-lg-4 col-md-5 col-xs-12">
<div class="esh-identity">
Expand Down
Loading

0 comments on commit d88293a

Please sign in to comment.