Impliment application

This commit is contained in:
2025-08-04 17:27:22 -07:00
parent 2d627733d7
commit 0a71162162
6 changed files with 285 additions and 4 deletions
@@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Mvc;
using BoredCareers.Services.DatabaseService;
using BoredCareers.Entities;
using System.Web.Http;
namespace BoredCareers.Controllers {
[ApiController]
[Route("api/application")]
public class ApplicationController : MistoxControllerBase {
public ApplicationController(DatabaseService db) : base(db) {}
[HttpGet]
public async Task<IActionResult> GetApplication(int ApplicationID) {
if (isLoggedIn()) {
Application? application = await _databaseService.GetApplication(ApplicationID);
if (application != null) {
return Ok(application);
}
return NotFound("Application doesn't exist");
}
return NotFound("Not logged in");
}
[HttpPost]
public async Task<IActionResult> SetApplication([FromBody] Application application) {
if (isLoggedIn()) {
if (application.AccountID == getLoggedInUserID()) {
await _databaseService.SetApplication(application);
return Ok();
}
return NotFound("Cannot apply for someone else");
}
return NotFound("Not logged in");
}
[HttpDelete]
public async Task<IActionResult> DeleteApplication(int ApplicationID) {
if (isLoggedIn()) {
Application? app = await _databaseService.GetApplication(ApplicationID);
if (app != null) {
if (app.AccountID == getLoggedInUserID()) {
await _databaseService.DeleteApplication(ApplicationID);
return Ok();
}
return NotFound("You cannot delete an app that isnt yours");
}
return NotFound("Application doesn't exist");
}
return NotFound("Not logged in");
}
}
}