Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #93 from martijnmelchers/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Martijn Melchers authored Jan 14, 2020
2 parents f10ab54 + 34a5aa8 commit 76c4fda
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/DomainServices/Services/AvailabilityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Availability GetUnavailabilityForDay(int employeeId, DateTime date)
{
return _db.Availabilities.FirstOrDefault(
a => a.Employee.Id == employeeId
&& _db.TruncateTime(a.StartTime) == _db.TruncateTime(date)
&& FestispecContext.TruncateTime(a.StartTime) == FestispecContext.TruncateTime(date)
&& a.EventTitle == "Niet beschikbaar");
}

Expand Down
2 changes: 1 addition & 1 deletion src/DomainServices/Services/InspectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task<List<PlannedInspection>> GetPlannedInspections(int employeeId)
{
var plannedInspections = await _db.PlannedInspections
.Include(e => e.Employee)
.Where(e => e.Employee.Id == employeeId && _db.TruncateTime(e.StartTime) == _db.TruncateTime(DateTime.Now))
.Where(e => e.Employee.Id == employeeId && FestispecContext.TruncateTime(e.StartTime) == FestispecContext.TruncateTime(DateTime.Now))
.ToListAsync();

if (plannedInspections.Count < 1)
Expand Down
2 changes: 1 addition & 1 deletion src/DomainServices/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static IServiceCollection AddDomainServices(this IServiceCollection servi
services.AddTransient<FestispecContext>();
services.AddScoped(typeof(ISyncService<>), typeof(JsonSyncService<>));
services.AddSingleton<IOfflineService, DbPollOfflineService>();
string environment = Environment.GetEnvironmentVariable("Environment") ?? "Debug";
string environment = Environment.GetEnvironmentVariable("Environment") ?? "Production";

var configuration = new ConfigurationBuilder()
.AddJsonFile($"appsettings.{environment}.json")
Expand Down
2 changes: 1 addition & 1 deletion src/DomainServices/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionString": "Server=tcp:festispec-e.database.windows.net,1433;Initial Catalog=Festispec;Persist Security Info=False;User ID=martijn;Password=w8UbnjG0kg%x2fyk;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"ConnectionString": "Server=tcp:festispec-e.database.windows.net,1433;Initial Catalog=Festispec;Persist Security Info=False;User ID=martijn;Password=w8UbnjG0kg%x2fyk;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=10;",
"ApiKeys": {
"Google": "AIzaSyB75U9ewy-e0nrRb4WKXXTTdalclxoipTs",
"Bing": "Ag2i7B-Uw8sWueLGS7BX7J5xYYKPJnynHsz7KYPQuE_cZAZItqMIQtYgE9mWIvkH"
Expand Down
7 changes: 4 additions & 3 deletions src/Models/EntityMapping/FestispecContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public override async Task<int> SaveChangesAsync()
AddTimestamps();
return await base.SaveChangesAsync();
}

public virtual DateTime? TruncateTime(DateTime dateTime)

[DbFunction("Edm", "TruncateTime")]
public static DateTime? TruncateTime(DateTime? dateValue)
{
return DbFunctions.TruncateTime(dateTime);
return dateValue?.Date;
}

private void AddTimestamps()
Expand Down
1 change: 0 additions & 1 deletion src/UnitTests/InspectionServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public InspectionServiceTests()
_dbMock.Setup(x => x.Questionnaires)
.Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Questionnaires).Object);
_dbMock.Setup(x => x.Employees).Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Employees).Object);
_dbMock.Setup(x => x.TruncateTime(It.IsAny<DateTime>())).Returns<DateTime>(dt => dt.Date);

// Create InspectionService
_inspectionService =
Expand Down
1 change: 0 additions & 1 deletion src/UnitTests/QuestionnaireTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public QuestionnaireTests()
.Returns(MockHelpers.CreateDbSetMock(new ModelMocks().PlannedInspections).Object);
_dbMock.Setup(x => x.Festivals).Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Festivals).Object);
_dbMock.Setup(x => x.Employees).Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Employees).Object);
_dbMock.Setup(x => x.TruncateTime(It.IsAny<DateTime>())).Returns<DateTime>(dt => dt.Date);
_dbMock.Setup(m => m.SaveChangesAsync()).ReturnsAsync(1);

_questionnaireService =
Expand Down

0 comments on commit 76c4fda

Please sign in to comment.