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_camController : ControllerBase { private readonly SqlContext _context; public Yuntech_camController(SqlContext context) { _context = context; } // GET: api/Yuntech_cam [HttpGet] public async Task>> Getyuntech_cam() { if (_context.yuntech_cam == null) { return NotFound(); } return await _context.yuntech_cam.ToListAsync(); } // GET: api/Yuntech_cam/5 [HttpGet("{id}")] public async Task> GetYuntech_cam(string id) { if (_context.yuntech_cam == null) { return NotFound(); } var yuntech_cam = await _context.yuntech_cam.FindAsync(id); if (yuntech_cam == null) { return NotFound(); } return yuntech_cam; } // PUT: api/Yuntech_cam/5 // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPut("{id}")] public async Task PutYuntech_cam(string id, Yuntech_cam yuntech_cam) { if (id != yuntech_cam.ip) { return BadRequest(); } _context.Entry(yuntech_cam).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Yuntech_camExists(id)) { return NotFound(); } else { throw; } } return NoContent(); } // POST: api/Yuntech_cam // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPost] public async Task> PostYuntech_cam(Yuntech_cam yuntech_cam) { if (_context.yuntech_cam == null) { return Problem("Entity set 'SqlContext.yuntech_cam' is null."); } _context.yuntech_cam.Add(yuntech_cam); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (Yuntech_camExists(yuntech_cam.ip)) { return Conflict(); } else { throw; } } return CreatedAtAction("GetYuntech_cam", new { id = yuntech_cam.ip }, yuntech_cam); } // DELETE: api/Yuntech_cam/5 [HttpDelete("{id}")] public async Task DeleteYuntech_cam(string id) { if (_context.yuntech_cam == null) { return NotFound(); } var yuntech_cam = await _context.yuntech_cam.FindAsync(id); if (yuntech_cam == null) { return NotFound(); } _context.yuntech_cam.Remove(yuntech_cam); await _context.SaveChangesAsync(); return NoContent(); } private bool Yuntech_camExists(string id) { return (_context.yuntech_cam?.Any(e => e.ip == id)).GetValueOrDefault(); } } }