Commit 4379e338 authored by Andres Käver's avatar Andres Käver
Browse files

.net upgrade, filtering in sessions

parent ba6ba56f
Pipeline #831 passed with stages
in 1 minute and 43 seconds
......@@ -10,7 +10,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.1" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
......@@ -21,9 +22,9 @@ namespace BLL.App.Services
}
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync()
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10, double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null, DateTime? toDateTime = null)
{
return (await Repository.GetAllForViewAsync()).Select(e => Mapper.MapGpsSessionView(e));
return (await Repository.GetAllForViewAsync(minLocationsCount, minDuration, minDistance, fromDateTime, toDateTime)).Select(e => Mapper.MapGpsSessionView(e));
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DAL.App.DTO;
......@@ -10,6 +11,6 @@ namespace Contracts.DAL.App.Repositories
public interface IGpsSessionRepositoryCustom<TGpsSessionView>
{
Task<IEnumerable<TGpsSessionView>> GetAllForViewAsync();
Task<IEnumerable<TGpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10, double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null, DateTime? toDateTime = null);
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
</ItemGroup>
</Project>
......@@ -5,9 +5,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
......@@ -34,14 +35,29 @@ namespace DAL.App.EF.Repositories
return result;
}
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync()
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10,
double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null,
DateTime? toDateTime = null)
{
return await RepoDbSet
var query = RepoDbSet
.Include(a => a.GpsSessionType)
.ThenInclude(a => a!.Name)
.ThenInclude(a => a!.Translations)
.Where(a => a.GpsLocations!.Count >= 10)
.OrderByDescending(a => a.RecordedAt)
.Where(a => a.GpsLocations!.Count >= minLocationsCount && a.Duration >= minDuration &&
a.Distance >= minDistance);
if (fromDateTime != null)
{
query = query.Where(a => a.RecordedAt >= fromDateTime);
}
if (toDateTime != null)
{
query = query.Where(a => a.RecordedAt <= toDateTime);
}
query = query
.OrderByDescending(a => a.RecordedAt);
var result = await query
.Select(a => new GpsSessionView()
{
Id = a.Id,
......@@ -59,6 +75,8 @@ namespace DAL.App.EF.Repositories
GpsSessionType = a.GpsSessionType!.Name,
UserFirstLastName = a.AppUser!.FirstName + " " + a.AppUser!.LastName,
}).ToListAsync();
return result;
}
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
</ItemGroup>
</Project>
......@@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>
</Project>
......@@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
......
......@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>
</Project>
......@@ -5,8 +5,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.1" />
</ItemGroup>
</Project>
......@@ -42,9 +42,11 @@ namespace WebApp.ApiControllers._1._0
[AllowAnonymous]
[Produces("application/json")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<V1DTO.GpsSessionView>))]
public async Task<ActionResult<IEnumerable<V1DTO.GpsSessionView>>> GetGpsSessions()
public async Task<ActionResult<IEnumerable<V1DTO.GpsSessionView>>> GetGpsSessions(int minLocationsCount = 10,
double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null,
DateTime? toDateTime = null)
{
var result = await _bll.GpsSessions.GetAllForViewAsync();
var result = await _bll.GpsSessions.GetAllForViewAsync(minLocationsCount, minDuration, minDistance, fromDateTime, toDateTime);
return Ok(result.Select(e => _mapper.MapGpsSessionView(e)));
}
......
......@@ -10,16 +10,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment