Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
com.akaver.sportmap
SportMap-ASPNET
Commits
a4e8d95b
Commit
a4e8d95b
authored
Jun 10, 2020
by
Andres Käver
Browse files
trackpoint filtering
parent
f62f1d35
Pipeline
#842
passed with stages
in 1 minute and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
BLL.App/Services/TrackPointService.cs
View file @
a4e8d95b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
BLL.App.DTO
;
using
BLL.App.Mappers
;
using
BLL.Base.Services
;
using
Contracts.BLL.App.Mappers
;
...
...
@@ -15,5 +20,10 @@ namespace BLL.App.Services
public
TrackPointService
(
IAppUnitOfWork
uow
)
:
base
(
uow
,
uow
.
TrackPoints
,
new
TrackPointServiceMapper
())
{
}
public
virtual
async
Task
<
IEnumerable
<
TrackPoint
>>
GetAllAsync
(
Guid
trackId
,
Guid
?
userId
=
null
,
bool
noTracking
=
true
)
{
return
(
await
Repository
.
GetAllAsync
(
trackId
,
userId
,
noTracking
)).
Select
(
e
=>
Mapper
.
Map
(
e
));
}
}
}
\ No newline at end of file
Contracts.DAL.App/Repositories/ITrackPointRepositoryCustom.cs
View file @
a4e8d95b
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
DAL.App.DTO
;
namespace
Contracts.DAL.App.Repositories
...
...
@@ -8,6 +11,6 @@ namespace Contracts.DAL.App.Repositories
}
public
interface
ITrackPointRepositoryCustom
<
TTrackPoint
>
{
Task
<
IEnumerable
<
TTrackPoint
>>
GetAllAsync
(
Guid
trackId
,
Guid
?
userId
=
null
,
bool
noTracking
=
true
);
}
}
\ No newline at end of file
DAL.App.EF/Repositories/TrackPointRepository.cs
View file @
a4e8d95b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Contracts.DAL.App.Repositories
;
using
Contracts.DAL.Base.Mappers
;
using
DAL.App.EF.Mappers
;
using
DAL.Base.EF.Repositories
;
using
DAL.Base.Mappers
;
using
Domain.App
;
using
Microsoft.EntityFrameworkCore
;
using
TrackPoint
=
DAL
.
App
.
DTO
.
TrackPoint
;
namespace
DAL.App.EF.Repositories
{
...
...
@@ -14,5 +20,15 @@ namespace DAL.App.EF.Repositories
public
TrackPointRepository
(
AppDbContext
repoDbContext
)
:
base
(
repoDbContext
,
new
DALMapper
<
Domain
.
App
.
TrackPoint
,
DTO
.
TrackPoint
>())
{
}
public
virtual
async
Task
<
IEnumerable
<
TrackPoint
>>
GetAllAsync
(
Guid
trackId
,
Guid
?
userId
=
null
,
bool
noTracking
=
true
)
{
var
query
=
PrepareQuery
(
userId
,
noTracking
);
query
=
query
.
Where
(
e
=>
e
.
TrackId
==
trackId
)
.
OrderBy
(
e
=>
e
.
PassOrder
).
ThenBy
(
e
=>
e
.
CreatedAt
);
var
domainEntities
=
await
query
.
ToListAsync
();
var
result
=
domainEntities
.
Select
(
e
=>
Mapper
.
Map
(
e
));
return
result
;
}
}
}
\ No newline at end of file
WebApp/ApiControllers/1.0/TrackPointsController.cs
View file @
a4e8d95b
...
...
@@ -44,9 +44,21 @@ namespace WebApp.ApiControllers._1._0
[
Produces
(
"application/json"
)]
[
Consumes
(
"application/json"
)]
[
ProducesResponseType
(
StatusCodes
.
Status200OK
,
Type
=
typeof
(
IEnumerable
<
V1DTO
.
Track
>))]
public
async
Task
<
ActionResult
<
IEnumerable
<
V1DTO
.
TrackPoint
>>>
GetTrackPoints
()
public
async
Task
<
ActionResult
<
IEnumerable
<
V1DTO
.
TrackPoint
>>>
GetTrackPoints
(
Guid
?
trackId
)
{
return
Ok
((
await
_bll
.
TrackPoints
.
GetAllAsync
()).
Select
(
e
=>
_mapper
.
Map
(
e
)));
if
(
trackId
==
null
)
{
return
BadRequest
(
new
V1DTO
.
MessageDTO
(
"trackId cannot be null"
));
}
if
(!
await
_bll
.
Tracks
.
ExistsAsync
(
trackId
.
Value
))
{
return
NotFound
(
new
V1DTO
.
MessageDTO
(
$"Track with id
{
trackId
}
was not found"
));
}
return
Ok
((
await
_bll
.
TrackPoints
.
GetAllAsync
(
trackId
.
Value
)).
Select
(
e
=>
_mapper
.
Map
(
e
)));
//return Ok((await _bll.TrackPoints.GetAllAsync()).Select(e => _mapper.Map(e)));
}
/// <summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment