/
HiddenLogic
/
Motion-ERP
Обзор
Документация
Войти
/
HiddenLogic
/
Motion-ERP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
Motion-ERP.API/Controllers/HandoverActsController.cs
68 строк
2 KB
adnet
Initial commit: Motion-ERP solution structure
30 июл 2026, 17:01
30 июл 2026, 17:01
bf32c92
Код
Авторство
О чём код?
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Motion_ERP_Application.DTOs; using Motion_ERP_Application.Interfaces; using Motion_ERP_Domain.Exceptions; namespace Motion_ERP_API.Controllers; [ApiController] [Route("api/[controller]")] [Authorize] public class HandoverActsController : ControllerBase { private readonly IHandoverService _handoverService; public HandoverActsController(IHandoverService handoverService) { _handoverService = handoverService; } [HttpGet] [ProducesResponseType(typeof(IEnumerable<HandoverActDto>), StatusCodes.Status200OK)] public async Task<ActionResult<IEnumerable<HandoverActDto>>> GetAll([FromQuery] Guid? contractId, [FromQuery] Guid? assetId, CancellationToken ct) { var acts = await _handoverService.GetAllAsync(contractId, assetId, ct); return Ok(acts); } [HttpGet("{id}")] [ProducesResponseType(typeof(HandoverActDto), StatusCodes.Status200OK)] public async Task<ActionResult<HandoverActDto>> GetById(Guid id, CancellationToken ct) { var act = await _handoverService.GetHandoverByIdAsync(id, ct); return act != null ? Ok(act) : NotFound(); } [HttpPost] [ProducesResponseType(typeof(HandoverActDto), StatusCodes.Status201Created)] public async Task<ActionResult<HandoverActDto>> Create(CreateHandoverActDto dto, CancellationToken ct) { try { var act = await _handoverService.CreateHandoverAsync(dto, ct); return CreatedAtAction(nameof(GetById), new { id = act.ActId }, act); } catch (DomainException ex) { return BadRequest(ex.Message); } } [HttpPost("{id}/return")] [ProducesResponseType(typeof(HandoverActDto), StatusCodes.Status200OK)] public async Task<ActionResult<HandoverActDto>> ReturnAsset(Guid id, ReturnHandoverActDto dto, CancellationToken ct) { try { var act = await _handoverService.ReturnAssetAsync(new ReturnHandoverActDto( dto.ActId, dto.ReturnTime, dto.ConditionBack, dto.PhotosBack, dto.Notes ), ct); return Ok(act); } catch (DomainException ex) { return BadRequest(ex.Message); } } }