parking-webapi/WebApi_data_value/Controllers/Yuntech_cam_total_tableController.cs

142 lines
4.5 KiB
C#
Raw Permalink Normal View History

2024-02-14 22:08:27 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
2024-03-05 19:49:58 +08:00
using Parking_space_WebAPI.Models;
using Parking_space_WebAPI.Authorization;
using Parking_space_WebAPI.Services;
2024-02-14 22:08:27 +08:00
2024-03-05 19:49:58 +08:00
namespace Parking_space_WebAPI.Controllers
2024-02-14 22:08:27 +08:00
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
2024-04-24 16:33:49 +08:00
[ApiExplorerSettings(GroupName = "校園大內網")]
2024-02-14 22:08:27 +08:00
public class Yuntech_cam_total_tableController : ControllerBase
{
private readonly SqlContext _context;
public Yuntech_cam_total_tableController(SqlContext context)
{
_context = context;
}
// GET: api/Yuntech_cam_total_table
[HttpGet]
public async Task<ActionResult<IEnumerable<Yuntech_cam_total_table>>> Getyuntech_cam_total_table()
{
if (_context.yuntech_cam_total_table == null)
{
return NotFound();
}
return await _context.yuntech_cam_total_table.ToListAsync();
}
// GET: api/Yuntech_cam_total_table/5
[HttpGet("{id}")]
public async Task<ActionResult<Yuntech_cam_total_table>> GetYuntech_cam_total_table(string id)
{
if (_context.yuntech_cam_total_table == null)
{
return NotFound();
}
var yuntech_cam_total_table = await _context.yuntech_cam_total_table.FindAsync(id);
if (yuntech_cam_total_table == null)
{
return NotFound();
}
return yuntech_cam_total_table;
}
// PUT: api/Yuntech_cam_total_table/5
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPut("{id}")]
public async Task<IActionResult> PutYuntech_cam_total_table(string id, Yuntech_cam_total_table yuntech_cam_total_table)
{
if (id != yuntech_cam_total_table.location_name)
{
return BadRequest();
}
_context.Entry(yuntech_cam_total_table).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!Yuntech_cam_total_tableExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Yuntech_cam_total_table
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPost]
public async Task<ActionResult<Yuntech_cam_total_table>> PostYuntech_cam_total_table(Yuntech_cam_total_table yuntech_cam_total_table)
{
if (_context.yuntech_cam_total_table == null)
{
return Problem("Entity set 'SqlContext.yuntech_cam_total_table' is null.");
}
_context.yuntech_cam_total_table.Add(yuntech_cam_total_table);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
{
if (Yuntech_cam_total_tableExists(yuntech_cam_total_table.location_name))
{
return Conflict();
}
else
{
throw;
}
}
return CreatedAtAction("GetYuntech_cam_total_table", new { id = yuntech_cam_total_table.location_name }, yuntech_cam_total_table);
}
// DELETE: api/Yuntech_cam_total_table/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteYuntech_cam_total_table(string id)
{
if (_context.yuntech_cam_total_table == null)
{
return NotFound();
}
var yuntech_cam_total_table = await _context.yuntech_cam_total_table.FindAsync(id);
if (yuntech_cam_total_table == null)
{
return NotFound();
}
_context.yuntech_cam_total_table.Remove(yuntech_cam_total_table);
await _context.SaveChangesAsync();
return NoContent();
}
private bool Yuntech_cam_total_tableExists(string id)
{
return (_context.yuntech_cam_total_table?.Any(e => e.location_name == id)).GetValueOrDefault();
}
}
}