Skip to content

Commit

Permalink
(#401) users: add devince info and wrappers domain
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Sep 1, 2024
1 parent 1dca354 commit 88624da
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
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; }
}
}
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();
}
}
}

0 comments on commit 88624da

Please sign in to comment.