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.Services; using WebApi_data_value.Models; using Parking_space_WebAPI.Authorization; namespace WebApi_data_value.Controllers { [Route("api/[controller]")] [ApiController] [Authorize] [ApiExplorerSettings(GroupName = "校園大內網")] public class Yuntech_parkingController : ControllerBase { private readonly SqlContext _context; public Yuntech_parkingController(SqlContext context) { _context = context; } // GET: api/Yuntech_parking [HttpGet] public async Task>> Getyuntech_parking() { if (_context.yuntech_parking == null) { return NotFound(); } return await _context.yuntech_parking.ToListAsync(); } // GET: api/Yuntech_parking/5 [HttpGet("{id}")] public async Task> GetYuntech_parking(string id) { if (_context.yuntech_parking == null) { return NotFound(); } var yuntech_parking = await _context.yuntech_parking.FindAsync(id); if (yuntech_parking == null) { return NotFound(); } return yuntech_parking; } // PUT: api/Yuntech_parking/5 // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPut("{id}")] public async Task PutYuntech_parking(string id, Yuntech_parking yuntech_parking) { if (id != yuntech_parking.all_num) { return BadRequest(); } _context.Entry(yuntech_parking).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Yuntech_parkingExists(id)) { return NotFound(); } else { throw; } } return NoContent(); } // POST: api/Yuntech_parking // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPost] public async Task> PostYuntech_parking(Yuntech_parking yuntech_parking) { if (_context.yuntech_parking == null) { return Problem("Entity set 'SqlContext.yuntech_parking' is null."); } _context.yuntech_parking.Add(yuntech_parking); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (Yuntech_parkingExists(yuntech_parking.all_num)) { return Conflict(); } else { throw; } } return CreatedAtAction("GetYuntech_parking", new { id = yuntech_parking.all_num }, yuntech_parking); } // DELETE: api/Yuntech_parking/5 [HttpDelete("{id}")] public async Task DeleteYuntech_parking(string id) { if (_context.yuntech_parking == null) { return NotFound(); } var yuntech_parking = await _context.yuntech_parking.FindAsync(id); if (yuntech_parking == null) { return NotFound(); } _context.yuntech_parking.Remove(yuntech_parking); await _context.SaveChangesAsync(); return NoContent(); } private bool Yuntech_parkingExists(string id) { return (_context.yuntech_parking?.Any(e => e.all_num == id)).GetValueOrDefault(); } } }