Endpoint
This commit is contained in:
parent
6f2a89481a
commit
07e2d6ef7e
@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TenantACustomisations.Database;
|
||||
using TenantACustomisations.ExternalServices;
|
||||
|
||||
namespace TenantACustomisations.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ShippingInformationsController : ControllerBase
|
||||
{
|
||||
private readonly TenantAContext _context;
|
||||
|
||||
public ShippingInformationsController(TenantAContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/ShippingInformations
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ShippingInformation>>> GetShippingInformation()
|
||||
{
|
||||
return await _context.ShippingInformation.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/ShippingInformations/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ShippingInformation>> GetShippingInformation(int id)
|
||||
{
|
||||
var shippingInformation = await _context.ShippingInformation.FindAsync(id);
|
||||
|
||||
if (shippingInformation == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return shippingInformation;
|
||||
}
|
||||
|
||||
// PUT: api/ShippingInformations/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutShippingInformation(int id, ShippingInformation shippingInformation)
|
||||
{
|
||||
if (id != shippingInformation.ShippingInformationId)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(shippingInformation).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!ShippingInformationExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/ShippingInformations
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ShippingInformation>> PostShippingInformation(ShippingInformation shippingInformation)
|
||||
{
|
||||
_context.ShippingInformation.Add(shippingInformation);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return CreatedAtAction("GetShippingInformation", new { id = shippingInformation.ShippingInformationId }, shippingInformation);
|
||||
}
|
||||
|
||||
// DELETE: api/ShippingInformations/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ShippingInformation>> DeleteShippingInformation(int id)
|
||||
{
|
||||
var shippingInformation = await _context.ShippingInformation.FindAsync(id);
|
||||
if (shippingInformation == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.ShippingInformation.Remove(shippingInformation);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return shippingInformation;
|
||||
}
|
||||
|
||||
private bool ShippingInformationExists(int id)
|
||||
{
|
||||
return _context.ShippingInformation.Any(e => e.ShippingInformationId == id);
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />
|
||||
<PackageReference Include="Polly" Version="6.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.9.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user