Last active
December 6, 2020 10:53
-
-
Save rahulsahay19/98e23bc22475ab976b35a3967c64203e to your computer and use it in GitHub Desktop.
MovieController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using MediatR; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Movies.Application.Commands; | |
using Movies.Application.Queries; | |
using Movies.Application.Responses; | |
namespace Movies.API.Controllers | |
{ | |
public class MovieController : ApiController | |
{ | |
private readonly IMediator _mediator; | |
public MovieController(IMediator mediator) | |
{ | |
_mediator = mediator; | |
} | |
[HttpGet] | |
[ProducesResponseType(StatusCodes.Status200OK)] | |
public async Task<ActionResult<IEnumerable<MovieResponse>>> GetMoviesByDirectorName(string directorName) | |
{ | |
var query = new GetMoviesByDirectorNameQuery(directorName); | |
var result = await _mediator.Send(query); | |
return Ok(result); | |
} | |
[HttpPost] | |
[ProducesResponseType(StatusCodes.Status200OK)] | |
public async Task<ActionResult<MovieResponse>> CreateMovie([FromBody] CreateMovieCommand command) | |
{ | |
var result = await _mediator.Send(command); | |
return Ok(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment