-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
96 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
11 changes: 11 additions & 0 deletions
11
MultiTenancyFramework.Core/Data/Queries/GetPhotosByOwnerIdAndImageTypeQuery.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,11 @@ | ||
using MultiTenancyFramework.Entities; | ||
using System.Collections.Generic; | ||
|
||
namespace MultiTenancyFramework.Data.Queries | ||
{ | ||
public sealed class GetPhotosByOwnerIdAndImageTypeQuery : IDbQuery<IList<Photo>> | ||
{ | ||
public string OwnerID { get; set; } | ||
public ImageType ImageType { 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 |
---|---|---|
@@ -1,12 +1,33 @@ | ||
namespace MultiTenancyFramework.Entities | ||
{ | ||
/// <summary> | ||
/// A person's photo record | ||
/// </summary> | ||
public class Photo : Entity | ||
{ | ||
public virtual long OwnerID { get; set; } | ||
/// <summary> | ||
/// The ID representing the person that owns this photo record | ||
/// </summary> | ||
public virtual string OwnerID { get; set; } | ||
|
||
/// <summary> | ||
/// The image, as byte array, typically to be saved in the Database | ||
/// </summary> | ||
public virtual byte[] Image { get; set; } | ||
|
||
/// <summary> | ||
/// Url (filepath) of the image, use when you're saving the image to disk, not database | ||
/// </summary> | ||
public virtual string ImageUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Image type | ||
/// </summary> | ||
public virtual ImageType ImageType { get; set; } | ||
|
||
/// <summary> | ||
/// Set to true by default. | ||
/// </summary> | ||
public override bool SkipAudit { get; set; } = true; | ||
} | ||
} |
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,16 @@ | ||
using MultiTenancyFramework.Entities; | ||
|
||
namespace MultiTenancyFramework.NHibernate.Maps | ||
{ | ||
public class PhotoMap : EntityMap<Photo> | ||
{ | ||
public PhotoMap() | ||
{ | ||
Map(x => x.Name); | ||
Map(x => x.Image); | ||
Map(x => x.ImageUrl); | ||
Map(x => x.ImageType); | ||
Map(x => x.OwnerID); | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
MultiTenancyFramework.NHibernate/Queries/GetPhotosByOwnerIdAndImageTypeQueryHandler.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,25 @@ | ||
using MultiTenancyFramework.Data.Queries; | ||
using MultiTenancyFramework.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MultiTenancyFramework.NHibernate.Queries | ||
{ | ||
public sealed class GetPhotosByOwnerIdAndImageTypeQueryHandler | ||
: CoreGeneralDAO, IDbQueryHandler<GetPhotosByOwnerIdAndImageTypeQuery, IList<Photo>> | ||
{ | ||
public IList<Photo> Handle(GetPhotosByOwnerIdAndImageTypeQuery theQuery) | ||
{ | ||
if (string.IsNullOrWhiteSpace(theQuery.OwnerID)) return new List<Photo>(); | ||
|
||
var session = BuildSession(); | ||
var query = session.QueryOver<Photo>() | ||
.Where(x => x.OwnerID == theQuery.OwnerID) | ||
.And(x => x.ImageType == theQuery.ImageType); | ||
return query.List(); | ||
} | ||
} | ||
} |
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