BaseRepository implementado

Siguiente video: 50 Implementar metodos personalizados
This commit is contained in:
Alejandro Sarmiento
2024-02-17 13:35:47 +01:00
parent ed5a0cceb0
commit 7ada54dbf5
55 changed files with 2299 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using CleanArchitecture.Application.Features.Streamers.Commands.CreateStreamer;
using CleanArchitecture.Application.Features.Streamers.Commands.DeleteStreamer;
using CleanArchitecture.Application.Features.Streamers.Commands.UpdateStreamer;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net;
namespace CleanArchitecture.API.Controllers
{
[Route("api/v1/[controller]")]
[ApiController]
public class StreamerController : ControllerBase
{
private readonly IMediator mediator;
public StreamerController(IMediator _mediator)
{
mediator = _mediator;
}
[HttpPost(Name = "CreateStreamer")]
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
public async Task<ActionResult<int>> CreateStreamer([FromBody] CreateStreamerCommand command)
{
var response = await mediator.Send(command);
return Ok(response);
}
[HttpPut(Name = "UpdateStreamer")]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
[ProducesDefaultResponseType]
public async Task<ActionResult> UpdateStreamer([FromBody] UpdateStreamerCommand command)
{
await mediator.Send(command);
return NoContent();
}
[HttpDelete("{id}", Name = "DeleteStreamer")]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
[ProducesDefaultResponseType]
public async Task<ActionResult> DeleteStreamer(int id)
{
var request = new DeleteStreamerCommand() { Id = id };
await mediator.Send(request);
return NoContent();
}
}
}

View File

@@ -0,0 +1,29 @@
using CleanArchitecture.Application.Features.Videos.Queries.GetVideosList;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net;
namespace CleanArchitecture.API.Controllers
{
[Route("api/v1/[controller]")]
[ApiController]
public class VideoController : ControllerBase
{
private readonly IMediator mediator;
public VideoController(IMediator _mediator)
{
mediator = _mediator;
}
[HttpGet("{username}", Name = "GetVideo")]
[ProducesResponseType(typeof(IEnumerable<VideosVm>), (int)HttpStatusCode.OK)]
public async Task<ActionResult<IEnumerable<VideosVm>>> GetVideosByUserName(string username)
{
var query = new GetVideosListQuery(username);
var videos = await mediator.Send(query);
return Ok(videos);
}
}
}