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 Parking_space_WebAPI.Models; using Parking_space_WebAPI.Authorization; using Parking_space_WebAPI.Services; namespace Parking_space_WebAPI.Controllers { [Route("api/[controller]")] [ApiController] [Authorize] [ApiExplorerSettings(GroupName = "校園大內網")] 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>> 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> 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 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> 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 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(); } } }