Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions BrixelAPI.SpaceAPI/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BrixelAPI.SpaceState.Features.UpdateState;
using BrixelAPI.SpaceState.Infrastructure;
using FluentValidation;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -13,7 +12,7 @@ public static class Bootstrapper
public static void Configure(IServiceCollection serviceCollection, IConfiguration configuration)
{
serviceCollection.AddMediatR(x => x.RegisterServicesFromAssembly(typeof(Bootstrapper).Assembly));

serviceCollection.AddScoped<ISpaceStateRepository, SpaceStateRepository>();
serviceCollection.AddScoped<ISpaceStateUnitOfWork, SpaceStateUnitOfWork>();

Expand Down
1 change: 0 additions & 1 deletion BrixelAPI.SpaceAPI/BrixelAPI.SpaceState.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.6" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions BrixelAPI.SpaceAPI/Domain/SpaceStateAggregate/SpaceState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using BrixelAPI.SpaceState.Schema;


namespace BrixelAPI.SpaceState.Domain.SpaceStateAggregate;

Expand All @@ -18,7 +18,7 @@ public static SpaceState GetConfiguredSpaceAPI()
{
return new SpaceState()
{
ApiCompatibility = new[] { "0.14" },
ApiCompatibility = ["0.14"],
Space = "Brixel",
Logo = "https://www.brixel.be/wp-content/uploads/2015/09/Logo_small_transparant.png",
Url = "http://brixel.be",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SpaceStateChangedLog
public DateTime ChangedAtDateTime { get; set; }
private SpaceStateChangedLog()
{

}

public static SpaceStateChangedLog Create(bool isOpen, string user)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using MediatR;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Features.GetFullStatus
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.IO;
using BrixelAPI.SpaceState.Infrastructure;
using MediatR;
using System;
using System.Threading;
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Domain.SpaceStateAggregate;
using BrixelAPI.SpaceState.Infrastructure;
using MediatR;

namespace BrixelAPI.SpaceState.Features.GetFullStatus
{
Expand All @@ -22,14 +20,15 @@ public async Task<GetFullStatusResponse> Handle(GetFullStatusRequest request, Ca
var state = Domain.SpaceStateAggregate.SpaceState.GetConfiguredSpaceAPI();
var lastState = await _spaceStateRepository.GetLastLogAsync();

if (lastState != null) {
if (lastState != null)
{

state.State.Open = lastState.IsOpen;
state.State.Lastchange = lastState.ChangedAtDateTime
.ToUniversalTime()
.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
}

var response = new GetFullStatusResponse(state);
return response;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using BrixelAPI.SpaceState.Schema;
using System.Linq;

namespace BrixelAPI.SpaceState.Features.GetFullStatus
{
Expand Down Expand Up @@ -42,5 +39,5 @@ public GetFullStatusResponse(Domain.SpaceStateAggregate.SpaceState spaceState)
}
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using MediatR;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Features.GetStateChangedLogs
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.ComponentModel;
using BrixelAPI.SpaceState.Infrastructure;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Infrastructure;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace BrixelAPI.SpaceState.Features.GetStateChangedLogs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BrixelAPI.SpaceState.Features.GetStateChangedLogs
{
public class GetStateChangedLogResponse
public class GetStateChangedLogResponse
{
public List<GetStateChangeLogDTO> Logs { get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
using MediatR;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Features.UpdateState
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Domain.SpaceStateAggregate;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using BrixelAPI.SpaceState.Infrastructure;
using MediatR;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Features.UpdateState
{
Expand All @@ -28,7 +27,7 @@ public async Task<ToggleIsOpenStateResponse> Handle(ToggleIsOpenStateRequest req
var state = Domain.SpaceStateAggregate.SpaceState.GetConfiguredSpaceAPI();

state.ChangeState(request.IsOpen);

await _spaceStateRepository.AddAsync(SpaceStateChangedLog.Create(request.IsOpen, "User"));

await _unitOfWork.CommitAsync();
Expand Down
2 changes: 1 addition & 1 deletion BrixelAPI.SpaceAPI/Infrastructure/ISpaceStateRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Infrastructure;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Threading;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Infrastructure.Migrations
{
Expand Down
6 changes: 3 additions & 3 deletions BrixelAPI.SpaceAPI/Infrastructure/SpaceStateRepository.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Infrastructure;

Expand All @@ -20,7 +20,7 @@ public async Task AddAsync(SpaceStateChangedLog spaceStateChangedLog)

public Task<SpaceStateChangedLog> GetLastLogAsync()
{
return
return
_context.SpaceStateChangedLog
.OrderByDescending(x => x.ChangedAtDateTime)
.FirstOrDefaultAsync();
Expand Down
4 changes: 2 additions & 2 deletions BrixelAPI.SpaceAPI/Infrastructure/SpaceStateUnitOfWork.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using BrixelAPI.SpaceState.Domain.SpaceStateChangedAggregate;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;

namespace BrixelAPI.SpaceState.Infrastructure
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using System;

namespace BrixelAPI.SpaceState.Migrations
{
Expand Down
Loading