Software_Engineering_Field_.../SiteManagementSystem(Softwa.../Controllers/FieldController.cs

31 lines
952 B
C#

using Microsoft.AspNetCore.Mvc;
using SiteManagementSystem_SoftwareEngineering_.Entity;
using SiteManagementSystem_SoftwareEngineering_.Extension;
using SiteManagementSystem_SoftwareEngineering_.Interface;
using SiteManagementSystem_SoftwareEngineering_.Service;
namespace SiteManagementSystem_SoftwareEngineering_.Controllers
{
[Route("Field")]
public class FieldController : ControllerBase
{
IFieldService _fieldService;
SQLService _sql;
public FieldController(IFieldService fieldService,SQLService sql) { _fieldService = fieldService; _sql = sql; }
[HttpPost("AddField")]
public IActionResult AddField()
{
_sql.Fields.Add(new Field());
_sql.SaveChanges();
return Ok();
}
[HttpGet("test")]
public IActionResult test()
{
_fieldService.AddField("", "");
return this.Success();
}
}
}