final
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-05-20 01:36:54 +02:00
parent beab15a7ef
commit 10c1bb008f
19 changed files with 1632 additions and 19 deletions

View File

@@ -1,10 +1,12 @@
using HanyadikHetVan.DTO;
using HanyadikHetVan.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Net.Mime;
using System.Threading.Tasks;
namespace HanyadikHetVan.Controllers.V2
@@ -52,5 +54,41 @@ namespace HanyadikHetVan.Controllers.V2
return NotFound();
}
}
[HttpDelete("{funfactId}")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(bool))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public async Task<IActionResult> DeleteFunFact(int funfactId)
{
var result = await _funfactService.DeleteFunFact(funfactId);
if (result)
{
return Ok(result);
}
else
{
return NotFound();
}
}
[HttpPut("{funfactId}")]
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(FunFactDTO))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public async Task<IActionResult> UpdatePause(int funfactId, [FromBody] FunFactDTO funfact)
{
try
{
var obj = await _funfactService.UpdateFunFact(funfactId, funfact);
return Ok(obj);
}
catch (Exception)
{
return NotFound();
}
}
}
}