This commit is contained in:
55
HanyadikHetVan/Controllers/V2/FunFactController.cs
Normal file
55
HanyadikHetVan/Controllers/V2/FunFactController.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using HanyadikHetVan.DTO;
|
||||
using HanyadikHetVan.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HanyadikHetVan.Controllers.V2
|
||||
{
|
||||
[ApiVersion("2.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class FunFactController : Controller
|
||||
{
|
||||
private readonly FunFactService _funfactService;
|
||||
|
||||
public FunFactController(FunFactService funfactService)
|
||||
{
|
||||
_funfactService = funfactService ?? throw new ArgumentNullException(nameof(funfactService));
|
||||
}
|
||||
|
||||
[HttpPut("{weeklytimespanId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(FunFactDTO))]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetFunFactOfWeeklyTimeSpan(int weeklytimespanId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = await _funfactService.GetFunFactOfWeeklyTimeSpan(weeklytimespanId);
|
||||
return Ok(obj);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{funfactId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(FunFactDTO))]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetFunFactorOfFunFact(int funfactId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = await _funfactService.GetFunFactorOfFunFact(funfactId);
|
||||
return Ok(obj);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user