initial commit
This commit is contained in:
63
Repository/DeploymentGroupRepository.cs
Normal file
63
Repository/DeploymentGroupRepository.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class DeploymentGroupRepository : IDeploymentGroupInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public DeploymentGroupRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<DeploymentGroupModel> GetDeploymentGroups()
|
||||
{
|
||||
return _context.DeploymentGroups.ToList();
|
||||
}
|
||||
|
||||
public DeploymentGroupModel GetDeploymentGroupById(Guid Id)
|
||||
{
|
||||
return _context.DeploymentGroups
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(tc => tc.TemplateCategory)
|
||||
.ThenInclude(s => s.Service)
|
||||
.Include(d => d.Deployments)
|
||||
.ThenInclude(vm => vm.VirtualMachine)
|
||||
.Where(dg => dg.Id == Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool AddDeploymentGroupById(DeploymentGroupModel deploymentgroup)
|
||||
{
|
||||
_context.Add(deploymentgroup);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool DeleteDeploymentGroupById(DeploymentGroupModel deploymentgroup)
|
||||
{
|
||||
_context.Remove(deploymentgroup);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool EditDeploymentGroupById(DeploymentGroupModel deploymentgroup)
|
||||
{
|
||||
_context.Update(deploymentgroup);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool CheckDeploymentGroupById(Guid Id)
|
||||
{
|
||||
return _context.DeploymentGroups
|
||||
.Any(d => d.Id == Id);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Repository/DeploymentRepository.cs
Normal file
61
Repository/DeploymentRepository.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class DeploymentRepository : IDeploymentInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public DeploymentRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<DeploymentModel> GetDeployments()
|
||||
{
|
||||
return _context.Deployments.ToList();
|
||||
}
|
||||
|
||||
public DeploymentModel GetDeploymentById(Guid Id)
|
||||
{
|
||||
return _context.Deployments
|
||||
.Include(vm => vm.VirtualMachine)
|
||||
.Include(dg => dg.DeploymentGroup)
|
||||
.ThenInclude(t => t.Template)
|
||||
.Where(d => d.Id == Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool AddDeploymentById(DeploymentModel deployment)
|
||||
{
|
||||
_context.Add(deployment);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool DeleteDeploymentById(DeploymentModel deployment)
|
||||
{
|
||||
_context.Remove(deployment);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool EditDeploymentById(DeploymentModel deployment)
|
||||
{
|
||||
_context.Update(deployment);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool CheckDeploymentById(Guid Id)
|
||||
{
|
||||
return _context.Deployments
|
||||
.Any(d => d.Id == Id);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
Repository/DomainRepository.cs
Normal file
88
Repository/DomainRepository.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class DomainRepository : IDomainInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public DomainRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ICollection<DomainModel> GetDomains()
|
||||
{
|
||||
return _context.Domains
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public DomainModel GetDomainById(Guid Id)
|
||||
{
|
||||
return _context.Domains
|
||||
.Where(d => d.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
public bool AddDomainById(DomainModel domain)
|
||||
{
|
||||
_context.Add(domain);
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool DeleteDomainById(DomainModel domain)
|
||||
{
|
||||
_context.Remove(domain);
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool EditDomainById(DomainModel domain)
|
||||
{
|
||||
_context.Update(domain);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public DomainModel GetDomainByIdInEnvironments(Guid Id)
|
||||
{
|
||||
return _context.Domains
|
||||
.Include(ed => ed.EnvironmentDomains)
|
||||
.ThenInclude(e => e.Environment)
|
||||
.Where(d => d.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
public DomainModel GetVirtualMachinesByDomainId(Guid Id)
|
||||
{
|
||||
return _context.Domains
|
||||
.Where(d => d.Id == Id)
|
||||
.Include(vm => vm.VirtualMachines)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool LinkDomainByIdToEnvironment(EnvironmentDomainsModel environmentDomain)
|
||||
{
|
||||
_context.Add(environmentDomain);
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool UnlinkDomainByIdFromEnvironment(EnvironmentDomainsModel environmentDomain)
|
||||
{
|
||||
_context.Remove(environmentDomain);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool CheckDomainById(Guid Id)
|
||||
{
|
||||
return _context.Domains
|
||||
.Any(d => d.Id == Id);
|
||||
}
|
||||
public bool CheckDomainByName(string Name)
|
||||
{
|
||||
return _context.Domains
|
||||
.Any(p => p.Name == Name);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Repository/EnvironmentRepository.cs
Normal file
75
Repository/EnvironmentRepository.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class EnvironmentRepository : IEnvironmentInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public EnvironmentRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<EnvironmentModel> GetEnvironments()
|
||||
{
|
||||
return _context.Environments.ToList();
|
||||
}
|
||||
|
||||
public EnvironmentModel GetEnvironmentById(Guid Id)
|
||||
{
|
||||
return _context.Environments
|
||||
.Where(e => e.Id == Id).FirstOrDefault();
|
||||
}
|
||||
public bool AddEnvironmentById(EnvironmentModel environment)
|
||||
{
|
||||
_context.Add(environment);
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool DeleteEnvironmentById(EnvironmentModel environment)
|
||||
{
|
||||
_context.Remove(environment);
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool EditEnvironmentById(EnvironmentModel environment)
|
||||
{
|
||||
_context.Update(environment);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public EnvironmentModel GetLinkedDomainsByEnvironmentId(Guid Id)
|
||||
{
|
||||
return _context.Environments
|
||||
.Include(ed => ed.EnvironmentDomains)
|
||||
.ThenInclude(d => d.Domain)
|
||||
.Where(e => e.Id == Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public ICollection<TemplateModel> GetAvailableTemplatesByEnvironmentId(Guid Id)
|
||||
{
|
||||
var environment = _context.Environments.Where(e => e.Id == Id).FirstOrDefault();
|
||||
|
||||
return _context.Templates.Where(t => t.CloudTemplate == environment.CloudEnabled).ToList();
|
||||
}
|
||||
|
||||
public bool CheckEnvironmentById(Guid Id)
|
||||
{
|
||||
return _context.Environments
|
||||
.Any(e => e.Id == Id);
|
||||
}
|
||||
public bool CheckEnvironmentByName(String Name)
|
||||
{
|
||||
return _context.Environments
|
||||
.Any(e => e.Name == Name);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Repository/JobRepository.cs
Normal file
56
Repository/JobRepository.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class JobRepository : IJobInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public JobRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<JobModel> GetJobs()
|
||||
{
|
||||
return _context.Jobs.ToList();
|
||||
}
|
||||
|
||||
bool IJobInterface.CheckJobById(Guid Id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IJobInterface.CreateJobById(JobModel job)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IJobInterface.DeleteJobById(JobModel job)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
JobModel IJobInterface.GetJobById(Guid Id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
ICollection<JobModel> IJobInterface.GetJobs()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IAbstractInterface.SaveChanges()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IJobInterface.UpdateJobById(JobModel job)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Repository/RunbookRepository.cs
Normal file
59
Repository/RunbookRepository.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class RunbookRepository : IRunbookInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public RunbookRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<RunbookModel> GetRunbooks()
|
||||
{
|
||||
return _context.Runbooks
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RunbookModel GetRunbookById(Guid Id)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Where(r => r.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool AddRunbookById(RunbookModel runbook)
|
||||
{
|
||||
_context.Add(runbook);
|
||||
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool EditRunbookById(RunbookModel runbook)
|
||||
{
|
||||
_context.Update(runbook);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool CheckRunbookById(Guid Id)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Any(r => r.Id == Id);
|
||||
}
|
||||
|
||||
public bool CheckRunbookByName(string Name)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Any(r => r.Name == Name);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Repository/ServiceRepository.cs
Normal file
48
Repository/ServiceRepository.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class ServiceRepository : IServiceInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public ServiceRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<ServiceModel> GetServices()
|
||||
{
|
||||
return _context.Services
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ServiceModel GetServiceById(Guid Id)
|
||||
{
|
||||
return _context.Services
|
||||
.Where(s=>s.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool CheckServiceById(Guid Id)
|
||||
{
|
||||
return _context.Services
|
||||
.Any(s =>s.Id == Id);
|
||||
}
|
||||
|
||||
public ServiceModel GetServiceByName(string Name)
|
||||
{
|
||||
return _context.Services
|
||||
.Where(s => s.Name == Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool CheckServiceByName(string Name)
|
||||
{
|
||||
return _context.Services
|
||||
.Any(s => s.Name == Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Repository/TemplateRepository.cs
Normal file
35
Repository/TemplateRepository.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class TemplateRepository : ITemplateInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public TemplateRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<TemplateModel> GetTemplates()
|
||||
{
|
||||
return _context.Templates
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TemplateModel GetTemplateById(Guid Id)
|
||||
{
|
||||
return _context.Templates
|
||||
.Where(t => t.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool CheckTemplateById(Guid Id)
|
||||
{
|
||||
return _context.Templates
|
||||
.Any(t => t.Id == Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Repository/VirtualMachineRepository.cs
Normal file
44
Repository/VirtualMachineRepository.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.SelfService.Portal.Core.API.Context;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Models;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Repository
|
||||
{
|
||||
public class VirtualMachineRepository : IVirtualMachineInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public VirtualMachineRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<VirtualMachineModel> GetVirtualMachines()
|
||||
{
|
||||
return _context.VirtualMachines
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public VirtualMachineModel GetVirtualMachineById(Guid Id)
|
||||
{
|
||||
return _context.VirtualMachines
|
||||
.Where(v => v.Id == Id)
|
||||
.Include(d => d.Domain)
|
||||
.ThenInclude(e => e.EnvironmentDomains)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool CheckVirtualMachineById(Guid Id)
|
||||
{
|
||||
return _context.VirtualMachines
|
||||
.Any(v => v.Id == Id);
|
||||
}
|
||||
|
||||
public bool CheckVirtualMachineByName(string Name)
|
||||
{
|
||||
return _context.VirtualMachines
|
||||
.Any(v => v.Name == Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user