Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,5 @@ GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml


.idea/.idea.Digipolis.Web/.idea/
24 changes: 0 additions & 24 deletions samples/Digipolis.Web.SampleApi/Configuration/Version2.cs

This file was deleted.

42 changes: 7 additions & 35 deletions samples/Digipolis.Web.SampleApi/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,19 @@ public ValuesController(IValueLogic valueLogic, ILogger<ValuesController> logger
/// <remarks>
/// This endpoint demostrates the use of the old <see cref="PagedResult{T}"/> and it's resulting json.
/// </remarks>
/// <param name="queryOptions">Query options from uri</param>
/// <returns>An array of value objects</returns>
[HttpGet()]
[ProducesResponseType(typeof(PagedResult<ValueDto>), 200)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
Copy link
Author

@XeNz XeNz Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versioning is currently probably broken

[Produces("application/hal+json")]
public IActionResult Get([FromQuery]CriteriaDto criteria)
{
int total;
var values = _valueLogic.GetAll(criteria, out total);
//var result = queryOptions.ToPagedResult(values, total, "kevin", new { test = 0 });
var result = criteria.ToPagedResult(values, total, "Get", "Values", new { test = 0 });
return Ok(result);
}

/// <summary>
/// Get all values
/// </summary>
/// <remarks>
/// This endpoint demostrates the use of the new <see cref="PagedResult{T, EmbeddedT}"/> and it's resulting json.
/// </remarks>
/// <param name="queryOptions">Query options from uri</param>
/// <returns>An array of value objects</returns>
[HttpGet("new")]
[ProducesResponseType(typeof(PagedResult<ValueDto, EmbeddedValueDto>), 200)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
[Produces("application/hal+json")]
public IActionResult GetNew([FromQuery]CriteriaDto criteria)
{
int total;
var values = _valueLogic.GetAll(criteria, out total);
//var result = queryOptions.ToPagedResult(values, total, "kevin", new { test = 0 });
var result = criteria.ToPagedResult<ValueDto, EmbeddedValueDto>(values, total);
var result = criteria.ToPagedResult(values, total, ControllerContext.ActionDescriptor.ActionName, ControllerContext.ActionDescriptor.ControllerName);
return Ok(result);
}

/// <summary>
/// Get a value by id
/// </summary>
Expand All @@ -85,7 +61,7 @@ public IActionResult Get(int id)
var value = _valueLogic.GetById(id);
return Ok(value);
}

/// <summary>
/// Add a new value
/// </summary>
Expand All @@ -95,13 +71,12 @@ public IActionResult Get(int id)
[ValidateModelState]
[ProducesResponseType(typeof(ValueDto), 201)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
public IActionResult Post([FromBody, Required] ValueDto value)
{
value = _valueLogic.Add(value);
return CreatedAtAction("Get", new { id = value.Id }, value);
}

/// <summary>
/// Update an existing value object
/// </summary>
Expand All @@ -110,34 +85,31 @@ public IActionResult Post([FromBody, Required] ValueDto value)
/// <returns></returns>
[HttpPut("{id}")]
[ValidateModelState]
[Versions(Versions.V1, Versions.V2)]
[ExcludeSwaggerResonse((int)HttpStatusCode.NotFound)]
public IActionResult Put(int id, [FromBody, Required] ValueDto value)
{
value = _valueLogic.Update(id, value);
return Ok(value);
}

/// <summary>
/// Delete a value by it's Id
/// </summary>
/// <param name="id">The value's Id</param>
/// <returns></returns>
[HttpDelete("{id}")]
[Versions(Versions.V2)]
public IActionResult Delete(int id)
{
_valueLogic.Delete(id);
return NoContent();
}

/// <summary>
/// Thorws an exception
/// Throws an exception
/// </summary>
/// <returns></returns>
[HttpGet("exception")]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
public IActionResult ThrowException()
{
throw new NotFoundException();
Expand Down
81 changes: 45 additions & 36 deletions samples/Digipolis.Web.SampleApi/Digipolis.Web.SampleApi.csproj
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Digipolis.Web.SampleApi</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Digipolis.Web.SampleApi</PackageId>
<RuntimeFrameworkVersion>2.1.6</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
<None Update="Views;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Digipolis.Web\Digipolis.Web.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="4.0.1" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Digipolis.Web.SampleApi</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Digipolis.Web.SampleApi</PackageId>
</PropertyGroup>

<ItemGroup>
<None Update="Views;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Digipolis.Web\Digipolis.Web.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0"/>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0"/>
<PackageReference Include="AutoMapper" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.0"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0"/>
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc5"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc5"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.0.0-rc5"/>
</ItemGroup>


<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml</DocumentationFile>
</PropertyGroup>


<ItemGroup>
<Folder Include="Swagger"/>
</ItemGroup>

</Project>
5 changes: 4 additions & 1 deletion samples/Digipolis.Web.SampleApi/Models/ChildDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
public class ChildDto
{
/// <summary>
/// The Id of the child
/// </summary>
public int Id { get; set; }
}
}
}
25 changes: 21 additions & 4 deletions samples/Digipolis.Web.SampleApi/Models/CriteriaDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,34 @@ namespace Digipolis.Web.SampleApi.Models
{
public class CriteriaDto : PageSortOptions
{
/// <summary>
/// Test bool
/// </summary>
public bool? TestBool { get; set; }


/// <summary>
/// Test String array
/// </summary>
public string[] StringArray { get; set; }

/// <summary>
/// Test String List
/// </summary>
public List<string> StringList { get; set; }

/// <summary>
/// Test Int Array
/// </summary>
public int[] IntArray { get; set; }

/// <summary>
/// Test Int List
/// </summary>
public List<int> IntList { get; set; }

/// <summary>
/// Test Complex array
/// </summary>
public ChildDto[] ComplexArray { get; set; }

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Digipolis.Web.SampleApi": {
"commandName": "Project",
"launchBrowser": true,
Expand Down
Loading