Finalize Services
This commit is contained in:
@@ -2,17 +2,8 @@ Server:
|
|||||||
Emails:
|
Emails:
|
||||||
Dont follow theme of website
|
Dont follow theme of website
|
||||||
|
|
||||||
Admin Functions:
|
|
||||||
Need to inforce Admin on the API side
|
|
||||||
|
|
||||||
Authentication ProductController:
|
|
||||||
When the create account is called. right after the getaccount is called.
|
|
||||||
Have all New for database return the object they create
|
|
||||||
|
|
||||||
Need to timeout email reset tokens:
|
Need to timeout email reset tokens:
|
||||||
|
|
||||||
Need to impliment Reset / Delte JobListingContorller
|
|
||||||
|
|
||||||
Client:
|
Client:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using BoredCareers.Services.DatabaseService;
|
||||||
|
using BoredCareers.Entities;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace BoredCareers.Controllers {
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/company/")]
|
||||||
|
public class CompanyController : MistoxControllerBase {
|
||||||
|
|
||||||
|
public CompanyController(DatabaseService db) : base(db) {}
|
||||||
|
|
||||||
|
[Route("get")]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> GetCompany([FromForm] int companyID) {
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
Company? company = await _databaseService.GetCompany(companyID);
|
||||||
|
if (company != null) {
|
||||||
|
return Ok(company);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("set")]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> SetCompany([FromBody] Company company) {
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
if (await isLoggedInUserEmployeeOf(company.ID)) {
|
||||||
|
await _databaseService.SetCompany(company);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("delete")]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> DeleteCompany([FromForm] int CompanyID) {
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
if (await isLoggedInUserEmployeeOf(CompanyID)) {
|
||||||
|
await _databaseService.DeleteCompany(CompanyID);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,17 +10,14 @@ namespace BoredCareers.Controllers {
|
|||||||
|
|
||||||
public JobListingController(DatabaseService db) : base(db) {}
|
public JobListingController(DatabaseService db) : base(db) {}
|
||||||
|
|
||||||
[Route("getlistings")]
|
[Route("getpage")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetJobListings([FromForm] int page) {
|
public async Task<IActionResult> GetJobListings([FromForm] int page) {
|
||||||
if (isLoggedIn()) {
|
|
||||||
JobListing[] jobListings = await _databaseService.GetJobListingPage(page, 25); // 10 items per page
|
JobListing[] jobListings = await _databaseService.GetJobListingPage(page, 25); // 10 items per page
|
||||||
return Ok(jobListings);
|
return Ok(jobListings);
|
||||||
}
|
}
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Route("getlisting")]
|
[Route("get")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetJobListing([FromForm] int JobListingID) {
|
public async Task<IActionResult> GetJobListing([FromForm] int JobListingID) {
|
||||||
JobListing? jobListing = await _databaseService.GetJobListing(JobListingID);
|
JobListing? jobListing = await _databaseService.GetJobListing(JobListingID);
|
||||||
@@ -32,16 +29,27 @@ namespace BoredCareers.Controllers {
|
|||||||
|
|
||||||
[Route("set")]
|
[Route("set")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> SetJobListing([FromBody] Resume resume) {
|
public async Task<IActionResult> SetJobListing([FromBody] JobListing jobListing) {
|
||||||
await Task.Delay(1);
|
if (isLoggedIn()) {
|
||||||
return Ok();
|
if (await isLoggedInUserEmployeeOf(jobListing.CompanyID)) {
|
||||||
|
await _databaseService.SetJobListing(jobListing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("delete")]
|
[Route("delete")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> DeleteJobListing([FromForm] int ResumeID) {
|
public async Task<IActionResult> DeleteJobListing([FromForm] int JobListingID) {
|
||||||
await Task.Delay(1);
|
if (isLoggedIn()) {
|
||||||
return Ok();
|
JobListing? jobListing = await _databaseService.GetJobListing(JobListingID);
|
||||||
|
if (jobListing != null) {
|
||||||
|
if (await isLoggedInUserEmployeeOf(JobListingID)) {
|
||||||
|
await _databaseService.DeleteJobListing(JobListingID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,16 @@ namespace BoredCareers.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> isLoggedInUserEmployeeOf(int CompanyID) {
|
||||||
|
Employee[] employees = await _databaseService.GetEmployees(CompanyID);
|
||||||
|
foreach (Employee cur in employees) {
|
||||||
|
if (getLoggedInUserID() == cur.AccountID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public string Substitue(string message, string subString, string Replacement) {
|
public string Substitue(string message, string subString, string Replacement) {
|
||||||
for (int i = 0; i < (message.Length - subString.Length); i++) {
|
for (int i = 0; i < (message.Length - subString.Length); i++) {
|
||||||
if (message.Substring(i, subString.Length) == subString) {
|
if (message.Substring(i, subString.Length) == subString) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace BoredCareers.Controllers {
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("getfull")]
|
[Route("get")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetResume([FromForm] int ResumeID) {
|
public async Task<IActionResult> GetResume([FromForm] int ResumeID) {
|
||||||
Resume? resume = await _databaseService.GetResume(ResumeID);
|
Resume? resume = await _databaseService.GetResume(ResumeID);
|
||||||
|
|||||||
Reference in New Issue
Block a user