Skip to content

Commit

Permalink
add more xml docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsonax committed May 9, 2024
1 parent ce3e77b commit 879d68e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
1 change: 0 additions & 1 deletion .run/CleanAspCore.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<method v="2">
<option name="Build" default="false" projectName="CleanAspCore" projectPath="$PROJECT_DIR$/CleanAspCore/CleanAspCore.csproj" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Run db" run_configuration_type="docker-deploy" />
</method>
</configuration>
</component>
3 changes: 3 additions & 0 deletions CleanAspCore/Features/Employees/Endpoints/AddEmployee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ public sealed class CreateEmployeeRequest
/// <summary>
/// The firstname of this employee.
/// </summary>
/// <example>Mary</example>
public required string FirstName { get; init; }

/// <summary>
/// The lastname of this employee.
/// </summary>
/// <example>Poppins</example>
public required string LastName { get; init; }

/// <summary>
Expand All @@ -28,6 +30,7 @@ public sealed class CreateEmployeeRequest
/// <summary>
/// The gender of this employee.
/// </summary>
/// <example>Female</example>
public required string Gender { get; init; }

/// <summary>
Expand Down
36 changes: 33 additions & 3 deletions CleanAspCore/Features/Employees/Endpoints/GetEmployeeById.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,58 @@
namespace CleanAspCore.Features.Employees.Endpoints;

/// <summary>
///
///
/// </summary>
public sealed class GetEmployeeResponse
{
/// <summary>
/// The id of this employee.
/// </summary>
public required Guid Id { get; init; }

/// <summary>
/// The firstname of this employee.
/// </summary>
/// <example>Mary</example>
public required string FirstName { get; init; }

/// <summary>
/// The lastname of this employee.
/// </summary>
/// <example>Poppins</example>
public required string LastName { get; init; }

/// <summary>
/// The email of this employee.
/// </summary>
public required string Email { get; init; }

/// <summary>
/// The gender of this employee.
/// </summary>
/// <example>Female</example>
public required string Gender { get; init; }

/// <summary>
/// The department id of which this employee is in.
/// </summary>
public required Guid DepartmentId { get; init; }

/// <summary>
/// The job id of this employee.
/// </summary>
public required Guid JobId { get; init; }
}

internal static class GetEmployeeById
{
internal static async Task<JsonHttpResult<GetEmployeeResponse>> Handle(Guid id, HrContext context, CancellationToken cancellationToken)
internal static async Task<Ok<GetEmployeeResponse>> Handle(Guid id, HrContext context, CancellationToken cancellationToken)
{
var result = await context.Employees
.Where(x => x.Id == id)
.Select(x => x.ToDto())
.FirstAsync(cancellationToken);
return TypedResults.Json(result);
return TypedResults.Ok(result);
}

private static GetEmployeeResponse ToDto(this Employee employee) => new()
Expand Down

0 comments on commit 879d68e

Please sign in to comment.