Skip to content

Commit

Permalink
Merge pull request #502 from DigitalExcellence/Release/v1.6.0-beta
Browse files Browse the repository at this point in the history
Release/v1.6.0 beta
  • Loading branch information
MeesvanStraten authored Sep 15, 2021
2 parents e8b347d + f976b4c commit 94490a6
Show file tree
Hide file tree
Showing 69 changed files with 452 additions and 329 deletions.
13 changes: 3 additions & 10 deletions API/01_API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@
<DocumentationFile>.\API.xml</DocumentationFile>
<Company>Digital Excellence Fontys</Company>
<LangVersion>8</LangVersion>
<Version>1.5.0-beta</Version>
<Version>1.6.0-beta</Version>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Resources\Project\**" />
<Content Remove="Resources\Project\**" />
<EmbeddedResource Remove="Resources\Project\**" />
<None Remove="Resources\Project\**" />
</ItemGroup>

<ItemGroup>
<None Remove="Uploads\Images\.gitkeep" />
</ItemGroup>
Expand All @@ -30,7 +23,7 @@
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="5.0.0" />
<PackageReference Include="IdentityModel.AspNetCore" Version="3.0.0" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -41,7 +34,7 @@
<PackageReference Include="Microsoft.OpenApi" Version="1.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="NetEscapades.Configuration.Validation" Version="2.0.0" />
<PackageReference Include="RestSharp" Version="106.11.4" />
<PackageReference Include="RestSharp" Version="106.12.0" />
<PackageReference Include="Sentry.AspNetCore" Version="2.1.1" />
<PackageReference Include="Sentry.Serilog" Version="2.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
Expand Down
98 changes: 49 additions & 49 deletions API/Configuration/MappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class MappingProfile : Profile
/// </summary>
public MappingProfile()
{
CreateMap<Project, AutocompleteProjectResourceResult>();
CreateMap<AutocompleteProjectResourceResult, Project>();
CreateMap<Project, AutocompleteProjectOutput>();
CreateMap<AutocompleteProjectOutput, Project>();

CreateMap<ProjectLike, UserProjectLikeResourceResult>()
CreateMap<ProjectLike, UserProjectLikeOutput>()
.ForMember(source => source.Id,
option => option
.MapFrom(destination =>
Expand All @@ -62,14 +62,14 @@ public MappingProfile()
destination.LikedProject.Description))
.ForAllOtherMembers(member => member.Ignore());

CreateMap<UserUserResourceResult, UserUser>();
CreateMap<UserUserOutput, UserUser>();

CreateMap<UserUser, UserUserResourceResult>()
CreateMap<UserUser, UserUserOutput>()
.ForMember(q => q.Id, opt => opt.MapFrom(q => q.FollowedUser.Id))
.ForMember(q => q.Name, opt => opt.MapFrom(q => q.FollowedUser.Name))
.ForAllOtherMembers(o => o.Ignore());

CreateMap<UserProject, UserProjectResourceResult>()
CreateMap<UserProject, UserProjectOutput>()
.ForMember(q => q.Id, opt => opt.MapFrom(p => p.Project.Id))
.ForMember(q => q.Name, opt => opt.MapFrom(p => p.Project.Name))
.ForMember(q => q.ShortDescription, opt => opt.MapFrom(p => p.Project.ShortDescription))
Expand All @@ -78,100 +78,100 @@ public MappingProfile()
.ForAllOtherMembers(o => o.Ignore());


CreateMap<User, UserResourceResult>()
CreateMap<User, UserOutput>()
.ForMember(q => q.UserTask, opt => opt.MapFrom(q => q.UserTasks))
.ForMember(q => q.ExpectedGraduationDateTime, opt => opt.MapFrom(q => q.ExpectedGraduationDate));

CreateMap<UserResource, User>()
CreateMap<UserInput, User>()
.ForMember(q => q.ExpectedGraduationDate, opt => opt.MapFrom(q => q.ExpectedGraduationDateTime));

CreateMap<User, LimitedUserResourceResult>();
CreateMap<User, LimitedUserOutput>();

CreateMap<ProjectResource, Project>()
CreateMap<ProjectInput, Project>()
.ForMember(q => q.Categories, opt => opt.Ignore());
CreateMap<Project, ProjectResourceResult>();
CreateMap<ProjectLike, ProjectLikesResourceResult>();
CreateMap<Project, ProjectHighlightResourceResult>();
CreateMap<Project, ProjectOutput>();
CreateMap<ProjectLike, ProjectLikesOutput>();
CreateMap<Project, ProjectHighlightOutput>();

CreateMap<CollaboratorResource, Collaborator>();
CreateMap<Collaborator, CollaboratorResourceResult>();
CreateMap<CollaboratorInput, Collaborator>();
CreateMap<Collaborator, CollaboratorOutput>();

CreateMap<Project, ProjectResultResource>();
CreateMap<Project, ProjectResultInput>();

CreateMap<ProjectFilterParamsResource, ProjectFilterParams>();
CreateMap<ProjectFilterParamsInput, ProjectFilterParams>();

CreateMap<HighlightResource, Highlight>();
CreateMap<Highlight, HighlightResourceResult>()
CreateMap<HighlightInput, Highlight>();
CreateMap<Highlight, HighlightOutput>()
.ForMember(e => e.Project,
opt => opt.MapFrom(d => d.Project));

CreateMap<RoleResource, Role>();
CreateMap<Role, RoleResourceResult>();
CreateMap<RoleInput, Role>();
CreateMap<Role, RoleOutput>();

CreateMap<CategoryResource, Category>();
CreateMap<Category, CategoryResourceResult>();
CreateMap<ProjectCategoryResource, ProjectCategory>();
CreateMap<ProjectCategory, ProjectCategoryResourceResult>()
CreateMap<CategoryInput, Category>();
CreateMap<Category, CategoryOutput>();
CreateMap<ProjectCategoryInput, ProjectCategory>();
CreateMap<ProjectCategory, ProjectCategoryOutput>()
.ForMember(q => q.Id, opt => opt.MapFrom(q=> q.Category.Id))
.ForMember(q => q.Name, opt => opt.MapFrom(q => q.Category.Name));

CreateMap<EmbeddedProjectResource, EmbeddedProject>();
CreateMap<EmbeddedProject, EmbeddedProjectResourceResult>();
CreateMap<EmbeddedProjectInput, EmbeddedProject>();
CreateMap<EmbeddedProject, EmbeddedProjectOutput>();

CreateMap<FileResourceResult, File>();
CreateMap<File, FileResourceResult>()
CreateMap<FileOutput, File>();
CreateMap<File, FileOutput>()
.ForMember(e => e.UploaderUserId,
opt => opt.MapFrom(e => e.Uploader.Id));

CreateMap<RoleScopeResource, RoleScope>();
CreateMap<RoleScope, RoleScopeResource>();
CreateMap<RoleScopeInput, RoleScope>();
CreateMap<RoleScope, RoleScopeInput>();

CreateMap<InstitutionResource, Institution>();
CreateMap<Institution, InstitutionResourceResult>();
CreateMap<InstitutionInput, Institution>();
CreateMap<Institution, InstitutionOutput>();

CreateMap<UserTask, UserTaskResourceResult>()
CreateMap<UserTask, UserTaskOutput>()
.ForMember(e => e.UserResourceResult,
opt => opt.MapFrom(d => d.User))
.ForMember(e => e.Id, opt => opt.MapFrom(e => e.Id))
.ForMember(e => e.Status, opt => opt.MapFrom(e => e.Status))
.ForMember(e => e.Type, opt => opt.MapFrom(e => e.Type));
CreateMap<Project, WizardProjectResourceResult>();
CreateMap<Project, WizardProjectOutput>();

CreateMap<IDataSourceAdaptee, DataSourceResourceResult>()
CreateMap<IDataSourceAdaptee, DataSourceOutput>()
.ForMember(dest => dest.WizardPages, opt => opt.MapFrom(src => src.DataSourceWizardPages));

CreateMap<DataSourceResource, DataSource>()
CreateMap<DataSourceInput, DataSource>()
.ForMember(dest => dest.DataSourceWizardPages, opt => opt.MapFrom(src => src.WizardPageResources));
CreateMap<DataSourceWizardPageResource, DataSourceWizardPage>();
CreateMap<DataSourceWizardPageInput, DataSourceWizardPage>();

CreateMap<DataSourceWizardPage, WizardPageResourceResult>()
CreateMap<DataSourceWizardPage, WizardPageOutput>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.WizardPage.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.WizardPage.Name));

CreateMap<DataSource, DataSourceResourceResult>()
CreateMap<DataSource, DataSourceOutput>()
.ForMember(dest => dest.WizardPages, opt => opt.MapFrom(src => src.DataSourceWizardPages));
CreateMap<IDataSourceAdaptee, DataSource>();

CreateMap<OauthTokens, OauthTokensResourceResult>();
CreateMap<OauthTokens, OauthTokensOutput>();

CreateMap<CallToActionResource, CallToAction>()
CreateMap<CallToActionInput, CallToAction>()
.ForMember(dest => dest.OptionValue, opt => opt.MapFrom(src => src.OptionValue.ToLower()));
CreateMap<CallToAction, CallToActionResourceResult>();
CreateMap<CallToAction, CallToActionOutput>();

CreateMap<CallToActionOptionResource, CallToActionOption>()
CreateMap<CallToActionOptionInput, CallToActionOption>()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.Type.ToLower()))
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.Value.ToLower()));
CreateMap<CallToActionOption, CallToActionOptionResourceResult>();
CreateMap<CallToActionOption, CallToActionOptionOutput>();

CreateMap<WizardPageResource, WizardPage>();
CreateMap<WizardPage, WizardPageResourceResult>();
CreateMap<WizardPageInput, WizardPage>();
CreateMap<WizardPage, WizardPageOutput>();

CreateMap<DataSourceWizardPage, DataSourceWizardPageResourceResult>()
CreateMap<DataSourceWizardPage, DataSourceWizardPageOutput>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.WizardPage.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.WizardPage.Name))
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.WizardPage.Description));

CreateMap<ProjectInstitution, ProjectInstitutionResourceResult>()
CreateMap<ProjectInstitution, ProjectInstitutionOutput>()
.ForMember(dest => dest.InstititutionName, opt => opt.MapFrom(src => src.Institution.Name))
.ForMember(dest => dest.ProjectName, opt => opt.MapFrom(src => src.Project.Name));

Expand Down
34 changes: 17 additions & 17 deletions API/Controllers/CallToActionOptionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public CallToActionOptionController(IMapper mapper, ICallToActionOptionService c
/// <response code="200">This endpoint returns a list of call to action options.</response>
[HttpGet]
[Authorize]
[ProducesResponseType(typeof(IEnumerable<CallToActionOptionResourceResult>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<CallToActionOptionOutput>), (int) HttpStatusCode.OK)]
public async Task<IActionResult> GetAllCallToActionOptions()
{
IEnumerable<CallToActionOption> options = await callToActionOptionService.GetAll();
IEnumerable<CallToActionOptionResourceResult> returnModel =
mapper.Map<IEnumerable<CallToActionOption>, IEnumerable<CallToActionOptionResourceResult>>(options);
IEnumerable<CallToActionOptionOutput> returnModel =
mapper.Map<IEnumerable<CallToActionOption>, IEnumerable<CallToActionOptionOutput>>(options);

return Ok(returnModel);
}
Expand All @@ -90,7 +90,7 @@ public async Task<IActionResult> GetAllCallToActionOptions()
/// <response code="404">The 404 Not Found status code is returned when the type could not be found.</response>
[HttpGet("type/{typeName}")]
[Authorize]
[ProducesResponseType(typeof(IEnumerable<CallToActionOptionResourceResult>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<CallToActionOptionOutput>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
public async Task<IActionResult> GetAllCallToActionOptionsFromType(string typeName)
Expand Down Expand Up @@ -122,8 +122,8 @@ public async Task<IActionResult> GetAllCallToActionOptionsFromType(string typeNa

IEnumerable<CallToActionOption> options =
await callToActionOptionService.GetCallToActionOptionsFromTypeAsync(typeName);
IEnumerable<CallToActionOptionResourceResult> returnModel =
mapper.Map<IEnumerable<CallToActionOption>, IEnumerable<CallToActionOptionResourceResult>>(options);
IEnumerable<CallToActionOptionOutput> returnModel =
mapper.Map<IEnumerable<CallToActionOption>, IEnumerable<CallToActionOptionOutput>>(options);

return Ok(returnModel);
}
Expand All @@ -141,7 +141,7 @@ public async Task<IActionResult> GetAllCallToActionOptionsFromType(string typeNa
/// </response>
[HttpGet("{id}")]
[Authorize]
[ProducesResponseType(typeof(CallToActionOptionResourceResult), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(CallToActionOptionOutput), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
public async Task<IActionResult> GetCallToActionOptionById(int id)
Expand Down Expand Up @@ -170,8 +170,8 @@ public async Task<IActionResult> GetCallToActionOptionById(int id)
return NotFound(problem);
}

CallToActionOptionResourceResult model =
mapper.Map<CallToActionOption, CallToActionOptionResourceResult>(callToActionOption);
CallToActionOptionOutput model =
mapper.Map<CallToActionOption, CallToActionOptionOutput>(callToActionOption);
return Ok(model);
}

Expand All @@ -190,9 +190,9 @@ public async Task<IActionResult> GetCallToActionOptionById(int id)
/// </response>
[HttpPost]
[Authorize(Policy = nameof(Defaults.Scopes.CallToActionOptionWrite))]
[ProducesResponseType(typeof(CallToActionOptionResourceResult), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(CallToActionOptionOutput), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.BadRequest)]
public async Task<IActionResult> CreateCallToActionOption(CallToActionOptionResource callToActionOptionResource)
public async Task<IActionResult> CreateCallToActionOption(CallToActionOptionInput callToActionOptionResource)
{
if(callToActionOptionResource == null)
{
Expand All @@ -206,7 +206,7 @@ public async Task<IActionResult> CreateCallToActionOption(CallToActionOptionReso
}

CallToActionOption option =
mapper.Map<CallToActionOptionResource, CallToActionOption>(callToActionOptionResource);
mapper.Map<CallToActionOptionInput, CallToActionOption>(callToActionOptionResource);

if((await callToActionOptionService.GetCallToActionOptionsFromTypeAsync(option.Type)).Any() &&
(await callToActionOptionService.GetCallToActionOptionFromValueAsync(option.Value)).Any())
Expand All @@ -224,8 +224,8 @@ public async Task<IActionResult> CreateCallToActionOption(CallToActionOptionReso
{
callToActionOptionService.Add(option);
callToActionOptionService.Save();
CallToActionOptionResourceResult model =
mapper.Map<CallToActionOption, CallToActionOptionResourceResult>(option);
CallToActionOptionOutput model =
mapper.Map<CallToActionOption, CallToActionOptionOutput>(option);
return Created(nameof(CreateCallToActionOption), model);
} catch(DbUpdateException)
{
Expand Down Expand Up @@ -257,11 +257,11 @@ public async Task<IActionResult> CreateCallToActionOption(CallToActionOptionReso
/// </response>
[HttpPut("{callToActionId}")]
[Authorize(Policy = nameof(Defaults.Scopes.CallToActionOptionWrite))]
[ProducesResponseType(typeof(CallToActionOptionResourceResult), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(CallToActionOptionOutput), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
public async Task<IActionResult> UpdateCallToActionOption(int callToActionId,
[FromBody]
CallToActionOptionResource callToActionOptionResource)
CallToActionOptionInput callToActionOptionResource)
{
CallToActionOption option = await callToActionOptionService.FindAsync(callToActionId);
if(option == null)
Expand Down Expand Up @@ -293,7 +293,7 @@ public async Task<IActionResult> UpdateCallToActionOption(int callToActionId,
callToActionOptionService.Update(option);
callToActionOptionService.Save();

return Ok(mapper.Map<CallToActionOption, CallToActionOptionResourceResult>(option));
return Ok(mapper.Map<CallToActionOption, CallToActionOptionOutput>(option));
}

/// <summary>
Expand Down
Loading

0 comments on commit 94490a6

Please sign in to comment.