Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: csharp
solution: SimplCommerce.sln
sudo: required
dist: xenial
dotnet: 2.2.401
dotnet: 3.0.100
mono: none
os:
- linux
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2.401 AS build-env
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100 AS build-env

WORKDIR /app
COPY . ./

RUN sed -i 's#<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />#<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.6" />#' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
RUN sed -i 's#<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />#<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0" />#' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
RUN sed -i 's/UseSqlServer/UseNpgsql/' src/SimplCommerce.WebHost/Program.cs
RUN sed -i 's/UseSqlServer/UseNpgsql/' src/SimplCommerce.WebHost/Extensions/ServiceCollectionExtensions.cs

Expand All @@ -23,7 +23,7 @@ RUN dotnet build -c Release \
# remove BOM for psql
RUN sed -i -e '1s/^\xEF\xBB\xBF//' /app/src/SimplCommerce.WebHost/dbscript.sql

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.6
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0

# hack to make postgresql-client install work on slim
RUN mkdir -p /usr/share/man/man1 \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-sqlite
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2.401 AS build-env
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100 AS build-env

WORKDIR /app
COPY . ./

RUN sed -i 's#<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />#<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />#' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
RUN sed -i 's#<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />#<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0" />#' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
RUN sed -i 's/UseSqlServer/UseSqlite/' src/SimplCommerce.WebHost/Program.cs
RUN sed -i 's/UseSqlServer/UseSqlite/' src/SimplCommerce.WebHost/Extensions/ServiceCollectionExtensions.cs
RUN sed -i 's/"DefaultConnection": ".*"/"DefaultConnection": "Data Source=simplcommerce.db"/' src/SimplCommerce.WebHost/appsettings.json
Expand All @@ -21,7 +21,7 @@ RUN dotnet build -c Release \
&& dotnet build -c Release \
&& dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.6
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0

RUN apt-get update \
&& apt-get install libgdiplus -y \
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Continuous deployment: https://ci.simplcommerce.com
#### Prerequisites

- SQL Server
- [Visual Studio 2019 version >= 16.2 with .NET Core SDK 2.2.401](https://www.microsoft.com/net/download/all)
- [Visual Studio 2019 version >= 16.2 with .NET Core SDK 3.0.100](https://www.microsoft.com/net/download/all)

#### Steps to run

Expand All @@ -41,7 +41,7 @@ Continuous deployment: https://ci.simplcommerce.com
#### Prerequisite

- PostgreSQL
- [.NET Core SDK 2.2.401](https://www.microsoft.com/net/download/all)
- [.NET Core SDK 3.0.100](https://www.microsoft.com/net/download/all)

#### Steps to run

Expand All @@ -52,9 +52,9 @@ Continuous deployment: https://ci.simplcommerce.com

## Technologies and frameworks used:

- ASP.NET MVC Core 2.2
- Entity Framework Core 2.2
- ASP.NET Identity Core 2.2
- ASP.NET MVC Core 3.0
- Entity Framework Core 3.0
- ASP.NET Identity Core 3.0
- Angular 1.6.3
- MediatR 7.0.0 for domain event

Expand Down
11 changes: 7 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
trigger:
- master

variables:
netCoreSdkVersion: '3.0.100'

jobs:
- job: Linux
pool:
Expand All @@ -14,7 +17,7 @@ jobs:
- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '2.2.401'
version: $(netCoreSdkVersion)
- script: dotnet build ./SimplCommerce.sln
displayName: 'dotnet build'
- script: ./run-tests.sh
Expand All @@ -33,7 +36,7 @@ jobs:
- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '2.2.401'
version: $(netCoreSdkVersion)
- script: dotnet build ./SimplCommerce.sln
displayName: 'dotnet build'
- script: ./run-tests.sh
Expand All @@ -52,7 +55,7 @@ jobs:
- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '2.2.401'
version: $(netCoreSdkVersion)
- script: dotnet build ./SimplCommerce.sln
displayName: 'dotnet build'
- task: PowerShell@2
Expand All @@ -75,7 +78,7 @@ jobs:
- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '2.2.401'
version: $(netCoreSdkVersion)
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- script: ./run-tests.sh
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.401"
"version": "3.0.100"
}
}
2 changes: 1 addition & 1 deletion simpl-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

sed -i'' -e 's|<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />|<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.0" />|' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
sed -i'' -e 's|<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />|<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0" />|' src/SimplCommerce.WebHost/SimplCommerce.WebHost.csproj
sed -i'' -e 's/UseSqlServer/UseNpgsql/' src/SimplCommerce.WebHost/Program.cs
sed -i'' -e 's/UseSqlServer/UseNpgsql/' src/SimplCommerce.WebHost/Extensions/ServiceCollectionExtensions.cs

Expand Down
5 changes: 3 additions & 2 deletions src/Modules/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project>
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void ConfigureServices(IServiceCollection services)
GlobalConfiguration.RegisterAngularModule("simplAdmin.activityLog");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ public IActionResult BrandDetail(long id, SearchOption searchOption)
query = query.Where(x => x.Price <= searchOption.MaxPrice.Value);
}

var categories = searchOption.GetCategories();
var categories = searchOption.GetCategories().ToArray();
if (categories.Any())
{
var categoryIds = _categoryRepository.Query().Where(x => categories.Contains(x.Slug)).Select(x => x.Id).ToList();
query = query.Where(x => x.Categories.Any(c => categoryIds.Contains(c.CategoryId)));
query = query.Where(x => x.Categories.Any(c => categories.Contains(c.Category.Slug)));
}

model.TotalProduct = query.Count();
Expand All @@ -88,15 +87,13 @@ public IActionResult BrandDetail(long id, SearchOption searchOption)
offset = (_pageSize * currentPageNum) - _pageSize;
}

query = query
.Include(x => x.ThumbnailImage);

query = AppySort(searchOption, query);

var products = query
.Select(x => ProductThumbnail.FromProduct(x))
.Include(x => x.ThumbnailImage)
.Skip(offset)
.Take(_pageSize)
.Select(x => ProductThumbnail.FromProduct(x))
.ToList();

foreach (var product in products)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ public IActionResult CategoryDetail(long id, SearchOption searchOption)
query = query.Where(x => x.Price <= searchOption.MaxPrice.Value);
}

var brands = searchOption.GetBrands();
var brands = searchOption.GetBrands().ToArray();
if (brands.Any())
{
var brandIds = _brandRepository.Query().Where(x => brands.Contains(x.Slug)).Select(x => x.Id).ToList();
query = query.Where(x => x.BrandId.HasValue && brandIds.Contains(x.BrandId.Value));
query = query.Where(x => x.BrandId != null && brands.Contains(x.Brand.Slug));
}

model.TotalProduct = query.Count();
Expand All @@ -98,16 +97,13 @@ public IActionResult CategoryDetail(long id, SearchOption searchOption)
offset = (_pageSize * currentPageNum) - _pageSize;
}

query = query
.Include(x => x.Brand)
.Include(x => x.ThumbnailImage);

query = ApplySort(searchOption, query);

var products = query
.Select(x => ProductThumbnail.FromProduct(x))
.Include(x => x.ThumbnailImage)
.Skip(offset)
.Take(_pageSize)
.Select(x => ProductThumbnail.FromProduct(x))
.ToList();

foreach (var product in products)
Expand Down Expand Up @@ -145,12 +141,12 @@ private static void AppendFilterOptionsToModel(ProductsByCategory model, IQuerya
model.FilterOption.Price.MaxPrice = query.Max(x => x.Price);
model.FilterOption.Price.MinPrice = query.Min(x => x.Price);

model.FilterOption.Brands = query
.Where(x => x.BrandId != null)
model.FilterOption.Brands = query.Include(x => x.Brand)
.Where(x => x.BrandId != null).ToList()
.GroupBy(x => x.Brand)
.Select(g => new FilterBrand
{
Id = (int)g.Key.Id,
Id = g.Key.Id,
Name = g.Key.Name,
Slug = g.Key.Slug,
Count = g.Count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@
<div>
<h3>@Localizer["Product specification"]</h3>
<table class="table table-striped">
@foreach (var attribute in Model.Attributes)
@foreach (var attr in Model.Attributes)
{
<tr>
<td>@attribute.Name</td>
<td>@attribute.Value</td>
<td>@attr.Name</td>
<td>@attr.Value</td>
</tr>
}
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void ConfigureServices(IServiceCollection services)
GlobalConfiguration.RegisterAngularModule("simplAdmin.catalog");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/SimplCommerce.Module.Cms/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void ConfigureServices(IServiceCollection services)
GlobalConfiguration.RegisterAngularModule("simplAdmin.cms");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services)
GlobalConfiguration.RegisterAngularModule("simplAdmin.comments");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void ConfigureServices(IServiceCollection serviceCollection)
GlobalConfiguration.RegisterAngularModule("simplAdmin.contacts");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@model ManageLoginsViewModel
@using Microsoft.AspNetCore.Http.Authentication
@using Microsoft.AspNetCore.Authentication
@{
ViewData["Title"] = "Manage your external logins";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public SimplSignInManager(UserManager<TUser> userManager,
IOptions<IdentityOptions> optionsAccessor,
ILogger<SignInManager<TUser>> logger,
IAuthenticationSchemeProvider schemes,
IUserConfirmation<TUser> confirmation,
IMediator mediator)
: base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemes)
: base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemes, confirmation)
{
_mediator = mediator;
}
Expand All @@ -32,4 +33,4 @@ public override async Task SignInAsync(TUser user, bool isPersistent, string aut
await base.SignInAsync(user, isPersistent, authenticationMethod);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore;
using SimplCommerce.Infrastructure.Data;
using SimplCommerce.Module.Core.Models;

namespace SimplCommerce.Module.Core.Extensions
{
public class SlugRouteValueTransformer : DynamicRouteValueTransformer
{
private readonly IRepository<Entity> _entityRepository;

public SlugRouteValueTransformer(IRepository<Entity> entityRepository)
{
_entityRepository = entityRepository;
}

public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext httpContext, RouteValueDictionary values)
{
var requestPath = httpContext.Request.Path.Value;

if (!string.IsNullOrEmpty(requestPath) && requestPath[0] == '/')
{
// Trim the leading slash
requestPath = requestPath.Substring(1);
}

var entity = await _entityRepository
.Query()
.Include(x => x.EntityType)
.FirstOrDefaultAsync(x => x.Slug == requestPath);

if(entity == null)
{
return null;
}

return new RouteValueDictionary
{
{ "area", entity.EntityType.AreaName },
{ "controller", entity.EntityType.RoutingController },
{ "action", entity.EntityType.RoutingAction },
{ "id", entity.EntityId }
};
}
}
}
Loading