82 lines
2.8 KiB
C#
82 lines
2.8 KiB
C#
using System.Linq.Expressions;
|
|
using console_spo_utils.Interfaces.Repositories;
|
|
using console_spo_utils.Interfaces.Services;
|
|
|
|
namespace console_spo_utils.Services;
|
|
|
|
internal class SharePointStructureBuilderService : ISharePointStructureBuilder
|
|
{
|
|
private readonly ISiteService siteService;
|
|
private readonly ISubProjectRepository subProjectRepository;
|
|
private readonly ISubProjectBuilderService subProjectBuilderService;
|
|
private readonly IQuotationBuildService quotationBuildService;
|
|
private readonly INonComplianceBuildService nonComplianceBuildService;
|
|
private readonly IWebpartService webpartService;
|
|
|
|
public SharePointStructureBuilderService(
|
|
ISiteService siteService,
|
|
ISubProjectRepository subProjectRepository,
|
|
ISubProjectBuilderService subProjectBuilderService,
|
|
IQuotationBuildService quotationBuildService,
|
|
INonComplianceBuildService nonComplianceBuildService,
|
|
IWebpartService webpartService)
|
|
{
|
|
this.siteService = siteService;
|
|
this.subProjectRepository = subProjectRepository;
|
|
this.subProjectBuilderService = subProjectBuilderService;
|
|
this.quotationBuildService = quotationBuildService;
|
|
this.nonComplianceBuildService = nonComplianceBuildService;
|
|
this.webpartService = webpartService;
|
|
}
|
|
|
|
|
|
public bool BuildProject(string projName)
|
|
{
|
|
var siteBuilderResult = siteService.CreateProjectSiteIfNotExists();
|
|
if (!siteBuilderResult)
|
|
{
|
|
throw new Exception($"Impossibile to build site");
|
|
}
|
|
var subSiteBuilderResult = siteService.CreateSubSiteIfNotExists(projName);
|
|
if (!subSiteBuilderResult)
|
|
{
|
|
throw new Exception($"Impossibile to build subSite for {projName} ");
|
|
}
|
|
|
|
|
|
var subProjects = subProjectRepository.GetFromProject(projName);
|
|
|
|
var subProjectBuilderResult = subProjectBuilderService.SubProjectDocSet(projName, subProjects);
|
|
if (!subProjectBuilderResult)
|
|
{
|
|
throw new Exception($"Impossibile to build subSite for {projName} ");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool BuildQuotation(string quotationName)
|
|
{
|
|
var siteBuildResult = siteService.CreateQuotationSiteIfNotExists(quotationName);
|
|
if (!siteBuildResult)
|
|
{
|
|
throw new Exception($"Impossibile to build site");
|
|
}
|
|
|
|
quotationBuildService.CreateIfNotExists(quotationName);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool BuildNonCompliance(string nonComplianceName)
|
|
{
|
|
var siteBuildResult = siteService.CreateNonComplianceSiteIfNotExists(nonComplianceName);
|
|
if (!siteBuildResult)
|
|
{
|
|
throw new Exception($"Impossibile to build site");
|
|
}
|
|
|
|
nonComplianceBuildService.CreateIfNotExists(nonComplianceName);
|
|
|
|
return true;
|
|
}
|
|
} |