Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added Status mapping and query processors
- Loading branch information
Showing
5 changed files
with
80 additions
and
0 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
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.Text; | ||
using System.Threading.Tasks; | ||
using BeyondEarthApp.Data.Entities; | ||
|
||
namespace BeyondEarthApp.Data.SqlServer.Mapping | ||
{ | ||
public class StatusMap : VersionedClassMap<Status> | ||
{ | ||
public StatusMap() | ||
{ | ||
Id(x => x.StatusId); | ||
Map(x => x.Name).Not.Nullable(); | ||
Map(x => x.Ordinal).Not.Nullable(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/BeyondEarthApp.Data.SqlServer/QueryProcessors/GameByIdQueryProcessor.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,22 @@ | ||
using BeyondEarthApp.Data.Entities; | ||
using BeyondEarthApp.Data.QueryProcessors; | ||
using NHibernate; | ||
|
||
namespace BeyondEarthApp.Data.SqlServer.QueryProcessors | ||
{ | ||
public class GameByIdQueryProcessor : IGameByIdQueryProcessor | ||
{ | ||
private readonly ISession _session; | ||
|
||
public GameByIdQueryProcessor(ISession session) | ||
{ | ||
_session = session; | ||
} | ||
|
||
public Game GetGame(long gameId) | ||
{ | ||
var game = _session.Get<Game>(gameId); | ||
return game; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/BeyondEarthApp.Data.SqlServer/QueryProcessors/UpdateGameStatusQueryProcessor.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,24 @@ | ||
using BeyondEarthApp.Data.Entities; | ||
using BeyondEarthApp.Data.QueryProcessors; | ||
using NHibernate; | ||
|
||
namespace BeyondEarthApp.Data.SqlServer.QueryProcessors | ||
{ | ||
public class UpdateGameStatusQueryProcessor : IUpdateGameStatusQueryProcessor | ||
{ | ||
private readonly ISession _session; | ||
|
||
public UpdateGameStatusQueryProcessor(ISession session) | ||
{ | ||
_session = session; | ||
} | ||
|
||
public void UpdateGameStatus(Game gameToUpdate, string statusName) | ||
{ | ||
var status = _session.QueryOver<Status>().Where(x => x.Name == statusName).SingleOrDefault(); | ||
gameToUpdate.Status = status; | ||
|
||
_session.SaveOrUpdate(gameToUpdate); | ||
} | ||
} | ||
} |
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