-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple UI for Users management. #27
- Loading branch information
Showing
44 changed files
with
1,261 additions
and
166 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
34 changes: 34 additions & 0 deletions
34
src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Queries/UserQueries.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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Baud.Deployment.BusinessLogic.Domain.Security.Entities; | ||
|
||
namespace Baud.Deployment.BusinessLogic.Domain.Security.Queries | ||
{ | ||
public static class UserQueries | ||
{ | ||
public static IQueryable<User> FilterByID(this IQueryable<User> query, int userID) | ||
{ | ||
return query.Where(x => x.ID == userID); | ||
} | ||
|
||
public static IQueryable<User> OnlyNonSystem(this IQueryable<User> query) | ||
{ | ||
return query.Where(x => !x.IsSystemUser); | ||
} | ||
|
||
public static IQueryable<User> OnlyActive(this IQueryable<User> query, DateTime? date = null) | ||
{ | ||
DateTime chosenDate = date ?? DateTime.Now; | ||
return query.Where(x => x.ActiveFrom <= chosenDate && (x.ActiveTo == null || x.ActiveTo > chosenDate)); | ||
} | ||
|
||
public static IQueryable<User> OnlyInactive(this IQueryable<User> query, DateTime? date = null) | ||
{ | ||
DateTime chosenDate = date ?? DateTime.Now; | ||
return query.Where(x => x.ActiveFrom > chosenDate || x.ActiveTo < chosenDate); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Server/DeploymentFramework/BusinessLogic/QueryableExtensions.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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Baud.Deployment | ||
{ | ||
public static class QueryableExtensions | ||
{ | ||
public static IQueryable<T> Filter<T>(this IQueryable<T> query, string filterValue, Expression<Func<T, bool>> predicate) | ||
{ | ||
if (!string.IsNullOrEmpty(filterValue)) | ||
{ | ||
return query.Where(predicate); | ||
} | ||
else | ||
{ | ||
return query; | ||
} | ||
} | ||
|
||
public static IQueryable<TItem> Filter<TItem, TStruct>(this IQueryable<TItem> query, IEnumerable<TStruct> filterValue, Expression<Func<TItem, bool>> predicate) where TStruct : struct | ||
{ | ||
if (filterValue != null && filterValue.Any()) | ||
{ | ||
return query.Where(predicate); | ||
} | ||
else | ||
{ | ||
return query; | ||
} | ||
} | ||
|
||
public static IQueryable<TItem> Filter<TItem, TStruct>(this IQueryable<TItem> query, TStruct? filterValue, Expression<Func<TItem, bool>> predicate) where TStruct : struct | ||
{ | ||
if (filterValue != null) | ||
{ | ||
return query.Where(predicate); | ||
} | ||
else | ||
{ | ||
return query; | ||
} | ||
} | ||
} | ||
} |
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
31 changes: 0 additions & 31 deletions
31
src/Server/DeploymentFramework/Database/Migrations/Configuration.cs
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/Server/DeploymentFramework/Database/Migrations/SecurityConfiguration.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,26 @@ | ||
namespace Baud.Deployment.Database.Migrations | ||
{ | ||
using System; | ||
using System.Data.Entity; | ||
using System.Data.Entity.Migrations; | ||
using System.Linq; | ||
using Baud.Deployment.BusinessLogic.Domain.Security.Entities; | ||
|
||
internal sealed class SecurityConfiguration : DbMigrationsConfiguration<Baud.Deployment.Database.Security.SecurityDbContext> | ||
{ | ||
public SecurityConfiguration() | ||
{ | ||
AutomaticMigrationsEnabled = true; | ||
} | ||
|
||
protected override void Seed(Baud.Deployment.Database.Security.SecurityDbContext context) | ||
{ | ||
var now = DateTime.Now; | ||
|
||
context.Users.AddOrUpdate( | ||
u => u.Login, | ||
new User { Login = "test", FirstName = "John", LastName = "Tester", ActiveFrom = new DateTime(2015, 5, 31), Email = "[email protected]", Created = now }, | ||
new User { Login = "demo", FirstName = "Jack", LastName = "Presenter", ActiveFrom = new DateTime(2015, 5, 31), Email = "[email protected]", Created = now }); | ||
} | ||
} | ||
} |
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
19 changes: 0 additions & 19 deletions
19
src/Server/DeploymentFramework/Web/App_Start/ContainerConfig.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.