Initial Commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WyvernInventory.Core.Interfaces.Services;
|
||||
using WyvernInventory.Core.Models;
|
||||
|
||||
namespace WyvernInventory.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class InventoryController(IDataObjectService<GenericInventoryItem> genericItemService)
|
||||
: ControllerBase
|
||||
{
|
||||
private readonly IDataObjectService<GenericInventoryItem> _genericItemService = genericItemService;
|
||||
|
||||
[HttpPost]
|
||||
public List<GenericInventoryItem> Get([FromBody] List<GenericInventoryItem> items)
|
||||
{
|
||||
return _genericItemService.GetAsync(_ => _).Result;
|
||||
}
|
||||
|
||||
[HttpPost("upsert")]
|
||||
public IResult Post([FromBody] List<GenericInventoryItem> items)
|
||||
{
|
||||
(int, int) results = _genericItemService.UpsertAsync(items).Result;
|
||||
|
||||
if (results.Item1 > 0 || results.Item2 > 0)
|
||||
{
|
||||
return Results.StatusCode(201);
|
||||
}
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public IResult Delete([FromRoute] int id)
|
||||
{
|
||||
_genericItemService.DeleteAsync(new() { new() { Id = id } }).Wait();
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WyvernInventory.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> GetBwah()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
[HttpGet("bwah", Name = "GetWeatherForecastBwah")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 2).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user