-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#401) users: add devince info and wrappers domain
- Loading branch information
1 parent
1dca354
commit 88624da
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
MiniSpace.Services.Students/src/MiniSpace.Services.Students.Core/Entities/DeviceInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace MiniSpace.Services.Students.Core.Entities | ||
{ | ||
public class DeviceInfo | ||
{ | ||
public string IpAddress { get; set; } | ||
public string DeviceType { get; set; } | ||
public string OperatingSystem { get; set; } | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
MiniSpace.Services.Students/src/MiniSpace.Services.Students.Core/Wrappers/PagedResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace MiniSpace.Services.Students.Core.Wrappers | ||
{ | ||
public class PagedResponse<T> | ||
{ | ||
public IEnumerable<T> Items { get; } | ||
public int TotalPages { get; } | ||
public int TotalItems { get; } | ||
public int PageSize { get; } | ||
public int Page { get; } | ||
public bool First { get; } | ||
public bool Last { get; } | ||
public bool Empty { get; } | ||
public int? NextPage => Page < TotalPages ? Page + 1 : (int?)null; | ||
public int? PreviousPage => Page > 1 ? Page - 1 : (int?)null; | ||
|
||
public PagedResponse(IEnumerable<T> items, int page, int pageSize, int totalItems) | ||
{ | ||
Items = items; | ||
PageSize = pageSize; | ||
TotalItems = totalItems; | ||
TotalPages = pageSize > 0 ? (int)Math.Ceiling((decimal)totalItems / pageSize) : 0; | ||
Page = page; | ||
First = page == 1; | ||
Last = page == TotalPages; | ||
Empty = !items.Any(); | ||
} | ||
} | ||
} |