-
-
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 core domain objects:
- Loading branch information
1 parent
bad506d
commit 6b3dc35
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...Space.Services.Students/src/MiniSpace.Services.Students.Core/Entities/UserProfileViews.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,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MiniSpace.Services.Students.Core.Entities | ||
{ | ||
public class UserProfileViews | ||
{ | ||
public Guid UserId { get; private set; } | ||
public IEnumerable<View> Views { get; private set; } | ||
|
||
public UserProfileViews(Guid userProfileId, IEnumerable<View> views) | ||
{ | ||
UserId = userProfileId; | ||
Views = views ?? new List<View>(); | ||
} | ||
|
||
public void AddView(Guid userProfileId, DateTime date) | ||
{ | ||
var viewList = new List<View>(Views) | ||
{ | ||
new View(userProfileId, date) | ||
}; | ||
Views = viewList; | ||
} | ||
|
||
public void RemoveView(Guid userProfileId) | ||
{ | ||
var viewList = new List<View>(Views); | ||
var viewToRemove = viewList.Find(view => view.UserProfileId == userProfileId); | ||
if (viewToRemove != null) | ||
{ | ||
viewList.Remove(viewToRemove); | ||
Views = viewList; | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
MiniSpace.Services.Students/src/MiniSpace.Services.Students.Core/Entities/View.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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace MiniSpace.Services.Students.Core.Entities | ||
{ | ||
public class View | ||
{ | ||
public Guid UserProfileId { get; private set; } | ||
public DateTime Date { get; private set; } | ||
|
||
public View(Guid postId, DateTime date) | ||
{ | ||
UserProfileId = postId; | ||
Date = date; | ||
} | ||
} | ||
} |