-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UpdatedAt, ArchivedAt and DeletedAt
- Loading branch information
Showing
12 changed files
with
114 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
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,10 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace SpeiderappAPI.Models.Interfaces | ||
{ | ||
public interface IArchivable | ||
{ | ||
public DateTime? ArchivedAt { get; set; } | ||
} | ||
} |
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.Linq; | ||
|
||
namespace SpeiderappAPI.Models.Interfaces | ||
{ | ||
public static class IArchivableExtensions | ||
{ | ||
public static IQueryable<TArchivable> ExcludeArchived<TArchivable>(this IQueryable<TArchivable> queryable) | ||
where TArchivable : IArchivable | ||
{ | ||
return queryable.Where(e => e.ArchivedAt == null); | ||
} | ||
|
||
public static IQueryable<TArchivable> OnlyArchived<TArchivable>(IQueryable<TArchivable> queryable) | ||
where TArchivable : IArchivable | ||
{ | ||
return queryable.Where(e => e.ArchivedAt != null); | ||
} | ||
} | ||
} |
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,9 @@ | ||
using System; | ||
|
||
namespace SpeiderappAPI.Models.Interfaces | ||
{ | ||
public interface ISoftDeletable | ||
{ | ||
public DateTime? DeletedAt { get; set; } | ||
} | ||
} |
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.Linq; | ||
|
||
namespace SpeiderappAPI.Models.Interfaces | ||
{ | ||
public static class ISoftDeleteExtensions | ||
{ | ||
public static IQueryable<TSoftDeletable> ExcludeDeleted<TSoftDeletable>( | ||
this IQueryable<TSoftDeletable> queryable) where TSoftDeletable : ISoftDeletable | ||
{ | ||
return queryable.Where(e => e.DeletedAt == null); | ||
} | ||
|
||
public static IQueryable<TSoftDeletable> OnlyDeleted<TSoftDeletable>(this IQueryable<TSoftDeletable> queryable) | ||
where TSoftDeletable : ISoftDeletable | ||
{ | ||
return queryable.Where(e => e.DeletedAt != null); | ||
} | ||
} | ||
} |
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,9 @@ | ||
using System; | ||
|
||
namespace SpeiderappAPI.Models.Interfaces | ||
{ | ||
public interface IUpdatable | ||
{ | ||
public DateTime UpdatedAt { get; set; } | ||
} | ||
} |
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
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
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
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