Первая часть работы с заявками
This commit is contained in:
@@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApplicationSystem.Contracts.Models.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Запрос на создание заявки
|
||||
/// </summary>
|
||||
public record ApplicationCreateRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Содержимое
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(1000)]
|
||||
public string Text { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Тип заявки
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Guid TypeId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Файл
|
||||
/// </summary>
|
||||
public IFormFile? File { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ApplicationSystem.Contracts\ApplicationSystem.Contracts.csproj" />
|
||||
<ProjectReference Include="..\ApplicationSystem.Identity\ApplicationSystem.Identity.csproj" />
|
||||
<ProjectReference Include="..\ApplicationSystem.MediatrHelper\ApplicationSystem.MediatRHelper.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\Queries\AplicationQueries\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Asp.Versioning;
|
||||
using ApplicationSystem.Models.Commands.ApplicationCommands;
|
||||
using Asp.Versioning;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -8,13 +10,16 @@ namespace ApplicationSystem.Controllers
|
||||
[Authorize]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class ApplicationsController : ControllerBase
|
||||
public class ApplicationsController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator = mediator;
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateApplicationAsync()
|
||||
public async Task<IActionResult> CreateApplicationAsync(
|
||||
[FromForm] ApplicationCreateCommand request)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
return Ok();
|
||||
var response = await _mediator.Send(request);
|
||||
return StatusCode((int)response.ResponseStatusCode);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using ApplicationSystem.Contracts.Models.Application;
|
||||
using ApplicationSystem.MediatRHelper.Models;
|
||||
|
||||
namespace ApplicationSystem.Models.Commands.ApplicationCommands
|
||||
{
|
||||
/// <summary>
|
||||
/// Запрос на создание заявки
|
||||
/// </summary>
|
||||
public record ApplicationCreateCommand
|
||||
: ApplicationCreateRequest, IRequestModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace ApplicationSystem.Models.Queries.AplicationQueries
|
||||
{
|
||||
public class ApplicationCreateCommand
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ using ApplicationSystem.Identity.Database.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||
builder.Services
|
||||
.AddControllers()
|
||||
.AddNewtonsoftJson();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
builder.Services.AddSwagger();
|
||||
|
||||
Reference in New Issue
Block a user