initial commit

This commit is contained in:
2026-04-15 15:02:32 +02:00
commit 3bfc79e6d9
1380 changed files with 69684 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.SelfService.Portal.Core.API.Dto.VirtualMachine.Get;
using Microsoft.SelfService.Portal.Core.API.Interfaces;
using Microsoft.SelfService.Portal.Core.API.Models;
namespace Microsoft.SelfService.Portal.Core.API.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class VirtualMachineController : Controller
{
private readonly IVirtualMachineInterface _virtualmachineInterface;
private readonly IMapper _mapper;
public VirtualMachineController(IVirtualMachineInterface virtualmachineInterface, IMapper mapper)
{
_virtualmachineInterface = virtualmachineInterface;
_mapper = mapper;
}
[HttpGet]
[ProducesResponseType(200, Type = typeof(IEnumerable<VirtualMachineModel>))]
public IActionResult GetVirtualMachines()
{
var virtualmachines = _mapper.Map<List<GetVirtualMachineDto>>(_virtualmachineInterface.GetVirtualMachines());
if (!ModelState.IsValid)
return BadRequest(ModelState);
return Ok(virtualmachines);
}
[HttpGet("{Id}")]
[ProducesResponseType(200, Type = typeof(VirtualMachineModel))]
[ProducesResponseType(400)]
public IActionResult GetVirtualMachineById(Guid Id)
{
if (!_virtualmachineInterface.CheckVirtualMachineById(Id))
return NotFound();
var virtualmachines = _mapper.Map<GetVirtualMachineDetailsDto>(_virtualmachineInterface.GetVirtualMachineById(Id));
if(!ModelState.IsValid)
return BadRequest(ModelState);
return Ok(virtualmachines);
}
}
}