Browse Source

project management CRUD AppService #629

pull/691/head
Yunus Emre Kalkan 8 years ago
parent
commit
444f7d5412
  1. 27
      modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/CreateProjectDto.cs
  2. 7
      modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs
  3. 13
      modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs
  4. 25
      modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/UpdateProjectDto.cs
  5. 59
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs
  6. 24
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs

27
modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/CreateProjectDto.cs

@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace Volo.Docs.Projects
{
public class CreateProjectDto
{
public string Name { get; set; }
public string ShortName { get; set; }
public string Format { get; set; }
public string DefaultDocumentName { get; set; }
public string NavigationDocumentName { get; set; }
public string MinimumVersion { get; set; }
public string MainWebsiteUrl { get; set; }
public string LatestVersionBranchName { get; set; }
public string DocumentStoreType { get; set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}
}

7
modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs

@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@ -9,6 +10,12 @@ namespace Volo.Docs.Projects
Task<ListResultDto<ProjectDto>> GetListAsync();
Task<ProjectDto> GetAsync(string shortName);
Task<ProjectDto> CreateAsync(CreateProjectDto input);
Task<ProjectDto> UpdateAsync(Guid id, UpdateProjectDto input);
Task DeleteAsync(Guid id);
Task<ListResultDto<VersionInfoDto>> GetVersionsAsync(string shortName);
}

13
modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace Volo.Docs.Projects
@ -10,12 +11,20 @@ namespace Volo.Docs.Projects
public string ShortName { get; set; }
public string Format { get; set; }
public string DefaultDocumentName { get; set; }
public string NavigationDocumentName { get; set; }
public string MinimumVersion { get; set; }
public string MainWebsiteUrl { get; set; }
public virtual string DocumentStoreType { get; protected set; }
public string LatestVersionBranchName { get; set; }
public string DocumentStoreType { get; set; }
public virtual string Format { get; protected set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}
}

25
modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/UpdateProjectDto.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace Volo.Docs.Projects
{
public class UpdateProjectDto
{
public string Name { get; set; }
public string Format { get; set; }
public string DefaultDocumentName { get; set; }
public string NavigationDocumentName { get; set; }
public string MinimumVersion { get; set; }
public string MainWebsiteUrl { get; set; }
public string LatestVersionBranchName { get; set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}
}

59
modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs

@ -6,6 +6,7 @@ using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.Guids;
using Volo.Docs.Documents;
namespace Volo.Docs.Projects
@ -15,15 +16,17 @@ namespace Volo.Docs.Projects
private readonly IProjectRepository _projectRepository;
private readonly IDistributedCache<List<VersionInfo>> _versionCache;
private readonly IDocumentStoreFactory _documentStoreFactory;
private readonly IGuidGenerator _guidGenerator;
public ProjectAppService(
IProjectRepository projectRepository,
IDistributedCache<List<VersionInfo>> versionCache,
IDocumentStoreFactory documentStoreFactory)
IDocumentStoreFactory documentStoreFactory, IGuidGenerator guidGenerator)
{
_projectRepository = projectRepository;
_versionCache = versionCache;
_documentStoreFactory = documentStoreFactory;
_guidGenerator = guidGenerator;
}
public async Task<ListResultDto<ProjectDto>> GetListAsync()
@ -42,6 +45,60 @@ namespace Volo.Docs.Projects
return ObjectMapper.Map<Project, ProjectDto>(project);
}
public async Task<ProjectDto> CreateAsync(CreateProjectDto input)
{
var project = new Project(_guidGenerator.Create(),
input.Name,
input.ShortName,
input.DocumentStoreType,
input.Format,
input.DefaultDocumentName,
input.NavigationDocumentName
)
{
MinimumVersion = input.MinimumVersion,
MainWebsiteUrl = input.MainWebsiteUrl,
LatestVersionBranchName = input.LatestVersionBranchName
};
foreach (var extraProperty in input.ExtraProperties)
{
project.ExtraProperties.Add(extraProperty.Key,extraProperty.Value);
}
project = await _projectRepository.InsertAsync(project);
return ObjectMapper.Map<Project, ProjectDto>(project);
}
public async Task<ProjectDto> UpdateAsync(Guid id, UpdateProjectDto input)
{
var project = await _projectRepository.GetAsync(id);
project.SetName(input.Name);
project.SetFormat(input.Format);
project.SetNavigationDocumentName(input.NavigationDocumentName);
project.SetDefaultDocumentName(input.DefaultDocumentName);
project.MinimumVersion = input.MinimumVersion;
project.MainWebsiteUrl = input.MainWebsiteUrl;
project.LatestVersionBranchName = input.LatestVersionBranchName;
foreach (var extraProperty in input.ExtraProperties)
{
project.ExtraProperties[extraProperty.Key] = extraProperty.Value;
}
project = await _projectRepository.UpdateAsync(project);
return ObjectMapper.Map<Project, ProjectDto>(project);
}
public async Task DeleteAsync(Guid id)
{
await _projectRepository.DeleteAsync(id);
}
public async Task<ListResultDto<VersionInfoDto>> GetVersionsAsync(string shortName)
{
var project = await _projectRepository.GetByShortNameAsync(shortName);

24
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs

@ -54,6 +54,8 @@ namespace Volo.Docs.Projects
Guid id,
[NotNull] string name,
[NotNull] string shortName,
[NotNull] string documentStoreType,
[NotNull] string format,
[NotNull] string defaultDocumentName,
[NotNull] string navigationDocumentName)
{
@ -61,10 +63,32 @@ namespace Volo.Docs.Projects
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
ShortName = Check.NotNullOrWhiteSpace(shortName, nameof(shortName));
DocumentStoreType = Check.NotNullOrWhiteSpace(documentStoreType, nameof(documentStoreType));
Format = Check.NotNullOrWhiteSpace(format, nameof(format));
DefaultDocumentName = Check.NotNullOrWhiteSpace(defaultDocumentName, nameof(defaultDocumentName));
NavigationDocumentName = Check.NotNullOrWhiteSpace(navigationDocumentName, nameof(navigationDocumentName));
ExtraProperties = new Dictionary<string, object>();
}
public void SetName(string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
}
public void SetFormat(string format)
{
Format = Check.NotNullOrWhiteSpace(format, nameof(format));
}
public void SetNavigationDocumentName(string navigationDocumentName)
{
NavigationDocumentName = Check.NotNullOrWhiteSpace(navigationDocumentName, nameof(navigationDocumentName));
}
public void SetDefaultDocumentName(string defaultDocumentName)
{
DefaultDocumentName = Check.NotNullOrWhiteSpace(defaultDocumentName, nameof(defaultDocumentName));
}
}
}
Loading…
Cancel
Save