Skip to content

Commit

Permalink
Added repository for deployments. #30
Browse files Browse the repository at this point in the history
  • Loading branch information
gius committed Jun 15, 2015
1 parent 9b8b3af commit 5472b7e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
<Compile Include="Contracts\IAgentAdapter.cs" />
<Compile Include="Contracts\ICurrentUserProvider.cs" />
<Compile Include="Contracts\IDateTimeProvider.cs" />
<Compile Include="Domain\Deployment\Contracts\IDeploymentUow.cs" />
<Compile Include="Domain\Deployment\Contracts\IInstallationsRepository.cs" />
<Compile Include="Domain\Deployment\Contracts\IProjectsRepository.cs" />
<Compile Include="Domain\Deployment\Entities\Application.cs" />
<Compile Include="Domain\Deployment\Entities\Installation.cs" />
Expand All @@ -73,6 +75,7 @@
<Compile Include="Domain\Deployment\Entities\ServerSite.cs" />
<Compile Include="Domain\Deployment\Enums\InstallationState.cs" />
<Compile Include="Domain\Deployment\Enums\LogSeverity.cs" />
<Compile Include="Domain\Deployment\Queries\InstallationQueries.cs" />
<Compile Include="Domain\EntityBase.cs" />
<Compile Include="Domain\IUow.cs" />
<Compile Include="Domain\Security\Contracts\ISecurityUow.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Baud.Deployment.BusinessLogic.Domain.Deployment.Contracts
{
public interface IDeploymentUow : IUow
{
IProjectsRepository Projects { get; }
IInstallationsRepository Installations { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Entities;

namespace Baud.Deployment.BusinessLogic.Domain.Deployment.Contracts
{
public interface IInstallationsRepository
{
IQueryable<Installation> GetWaitingInstallations();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Entities;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Enums;

namespace Baud.Deployment.BusinessLogic.Domain.Deployment.Queries
{
public static class InstallationQueries
{
public static IQueryable<Installation> OnlyWaiting(this IQueryable<Installation> query)
{
return query.Where(x => x.State == InstallationState.Waiting);
}

public static IQueryable<Installation> OnlyPlannedBefore(this IQueryable<Installation> query, DateTime date)
{
return query.Where(x => x.Planned <= date);
}
}
}
2 changes: 2 additions & 0 deletions src/Server/DeploymentFramework/Database/Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<Compile Include="Contracts\IDbContextProvider.cs" />
<Compile Include="Contracts\IRepositoryProvider.cs" />
<Compile Include="Deployment\DeploymentDbContext.cs" />
<Compile Include="Deployment\DeploymentUow.cs" />
<Compile Include="Deployment\InstallationsRepository.cs" />
<Compile Include="Migrations\DeploymentConfiguration.cs" />
<Compile Include="Migrations\SecurityConfiguration.cs" />
<Compile Include="NonTrackingDbContextProvider.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Baud.Deployment.BusinessLogic.Contracts;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Contracts;
using Baud.Deployment.Database.Contracts;

namespace Baud.Deployment.Database.Deployment
{
public class DeploymentUow : UowBase<DeploymentDbContext>, IDeploymentUow
{
public IProjectsRepository Projects
{
get { return GetRepository<IProjectsRepository>(); }
}

public IInstallationsRepository Installations
{
get { return GetRepository<IInstallationsRepository>(); }
}

public DeploymentUow(IDbContextProvider<DeploymentDbContext> contextProvider, IRepositoryProvider<DeploymentDbContext> repositoryProvider, ICurrentUserProvider currentUserProvider, IDateTimeProvider dateTimeProvider)
: base(contextProvider, repositoryProvider, currentUserProvider, dateTimeProvider)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Contracts;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Entities;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Queries;

namespace Baud.Deployment.Database.Deployment
{
public class InstallationsRepository : RepositoryBase<DeploymentDbContext>, IInstallationsRepository
{
public InstallationsRepository(DeploymentDbContext context)
: base(context)
{
}

public IQueryable<Installation> GetWaitingInstallations()
{
var now = DateTime.Now;

return Context.Installations
.Include(x => x.DeployTarget.Application)
.Include(x => x.DeployTarget.Server)
.OnlyWaiting()
.OnlyPlannedBefore(now);
}
}
}

0 comments on commit 5472b7e

Please sign in to comment.