2022-05-11 12:04:56 -07:00
|
|
|
using API.Errors;
|
|
|
|
using Infrastructure.Data;
|
2022-05-19 15:47:12 -07:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2022-05-11 12:04:56 -07:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace API.Controllers
|
|
|
|
{
|
|
|
|
public class BuggyController : BaseApiController
|
|
|
|
{
|
|
|
|
private readonly StoreContext _context;
|
|
|
|
public BuggyController(StoreContext context)
|
|
|
|
{
|
|
|
|
_context = context;
|
|
|
|
}
|
|
|
|
|
2022-05-19 15:47:12 -07:00
|
|
|
[HttpGet("testauth")]
|
|
|
|
[Authorize]
|
|
|
|
public ActionResult<string> GetSecretText()
|
|
|
|
{
|
|
|
|
return "secret stuff";
|
|
|
|
}
|
|
|
|
|
2022-05-11 12:04:56 -07:00
|
|
|
[HttpGet("notfound")]
|
|
|
|
public ActionResult GetNotFoundRequest()
|
|
|
|
{
|
|
|
|
var thing = _context.Products.Find(42);
|
|
|
|
if (thing == null)
|
|
|
|
{
|
|
|
|
return NotFound(new ApiResponse(404));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("servererror")]
|
|
|
|
public ActionResult GetServerError()
|
|
|
|
{
|
|
|
|
var thing = _context.Products.Find(42);
|
|
|
|
var thingToReturn = thing.ToString();
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("badrequest")]
|
|
|
|
public ActionResult GetBadRequest()
|
|
|
|
{
|
|
|
|
return BadRequest(new ApiResponse(400));
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("badrequest/{id}")]
|
|
|
|
public ActionResult GetNotFoundRequest(int id)
|
|
|
|
{
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|