Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ID Numbers from Membership & Request Endpoints #720

Merged
merged 55 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
67a1ab0
save progress
bennettforkner Sep 19, 2022
657ba57
Merge branch 'develop' into remove_membership_account_by_email
bennettforkner Sep 22, 2022
f0d858e
Remove ID #s from objects pased through the MembershipController
bennettforkner Sep 22, 2022
c0a2d2a
replace id numbers in memberships
bennettforkner Sep 23, 2022
8115d50
cleaning up logic for checking matching records
bennettforkner Sep 26, 2022
ea077cb
Switching to LF
bennettforkner Sep 26, 2022
0a16903
Updating EOL sequence
bennettforkner Sep 26, 2022
f827bbe
forcing LF
bennettforkner Sep 26, 2022
3762f51
Changing CRLF back to LF in all DbModels
bennettforkner Sep 26, 2022
5aaa4ae
LF for Services
bennettforkner Sep 26, 2022
7496e72
LF for Services
bennettforkner Sep 26, 2022
bd80280
LF for Services
bennettforkner Sep 26, 2022
94704fe
Removing unused service method
bennettforkner Sep 26, 2022
9e34a28
force LF
bennettforkner Sep 26, 2022
5c2621b
Save progress
bennettforkner Sep 29, 2022
addca7f
Update MembershipRequest endpoints to remove ID_NUM
bennettforkner Oct 6, 2022
35ab654
Cleanup and changes requested by @EJPlatzer
bennettforkner Oct 14, 2022
30843c7
Updating UploadViewModels with more friendly parameters for @EJPlatze…
bennettforkner Oct 14, 2022
88fba84
Remove ID Numbers from Admin
bennettforkner Oct 14, 2022
766bb6c
Fix call to admin service & allow filtering requests by status
bennettforkner Oct 14, 2022
4601698
Re-add membershipservice to emailservice
bennettforkner Oct 14, 2022
c1e3dfd
Remove WebHostEnvironment from StateYourBusiness
bennettforkner Oct 14, 2022
c13cf00
Fix issues with membershipService and accountService
bennettforkner Oct 14, 2022
90c6792
Remove duplicate endpoint
bennettforkner Oct 14, 2022
7e82a46
Merge branch 'develop' into remove_membership_account_by_email
bennettforkner Oct 14, 2022
fa1d068
Simplify logic for username
bennettforkner Oct 14, 2022
a2d3f15
Remove extra semicolon
bennettforkner Oct 17, 2022
d227ae2
Make RequestView nullable in update
bennettforkner Oct 17, 2022
e827f57
Organize and rewrite XML comments
bennettforkner Oct 17, 2022
6151fed
Remove unused methods
bennettforkner Oct 17, 2022
1b2ce9c
Remove method from interface -- missed in last commit
bennettforkner Oct 17, 2022
86f4eb8
Revert changes to PreserveCasingWithRegex
bennettforkner Oct 17, 2022
c18f52c
Changes requested by @EJPlatzer
bennettforkner Oct 17, 2022
8e6130f
Remove unnecessary try catch and allow null pass/return from implicit…
bennettforkner Oct 17, 2022
9afb642
Use dependency injection instead of new instance in constructor
bennettforkner Oct 17, 2022
a72895b
Add News Interface and fix recursive get on requests service
bennettforkner Oct 17, 2022
127c29d
Re-add logic to check for existing identical request/s
bennettforkner Oct 17, 2022
d0921e9
Fixing misc broken functionality
bennettforkner Oct 18, 2022
cb8823e
Handle null case in service method
bennettforkner Oct 19, 2022
28a6fe3
Change MEMBERSHIP to MembershipView on MC.Delete
bennettforkner Nov 2, 2022
e93d241
Merge branch 'develop' into remove_membership_account_by_email
bennettforkner Nov 2, 2022
28cd20d
Merge branch 'develop' into remove_membership_account_by_email
bennettforkner Nov 11, 2022
041e976
simplify logic for housing admin check
bennettforkner Nov 11, 2022
f3d4e60
Simplify logic for visible memberships on profile
bennettforkner Nov 11, 2022
41a471f
Remove status from SYB logic
bennettforkner Nov 14, 2022
f05e76a
Convert switch into switch expression
bennettforkner Nov 14, 2022
e5fa8ae
Remove public tag as methods are public by default
bennettforkner Nov 14, 2022
30a7c48
Remove semicolon in switch statement
bennettforkner Nov 14, 2022
928272f
Correct namespace of viewmodel
bennettforkner Nov 15, 2022
ad35dfb
use CCT models
bennettforkner Nov 15, 2022
a0b7ccc
use viewmodels in StateYourBusiness
bennettforkner Nov 15, 2022
465562a
Merge branch 'develop' into remove_membership_account_by_email
bennettforkner Nov 16, 2022
4f4bdcd
merge in develop
bennettforkner Nov 16, 2022
c8aade4
Add IsAlumni to MembershipView in database
bennettforkner Nov 16, 2022
a9c8001
Delete MembershipViewModel as it is replaced by MembershipView
bennettforkner Nov 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=lf

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cs text
*.json text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
380 changes: 168 additions & 212 deletions Gordon360/Authorization/StateYourBusiness.cs

Large diffs are not rendered by default.

36 changes: 9 additions & 27 deletions Gordon360/Controllers/AdminsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Gordon360.Authorization;
using Gordon360.Models.CCT.Context;
using Gordon360.Models.CCT;
using Gordon360.Models.ViewModels;
using Gordon360.Services;
using Gordon360.Static.Names;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -13,9 +14,9 @@ public class AdminsController : GordonControllerBase
{
private readonly IAdministratorService _adminService;

public AdminsController(CCTContext context)
public AdminsController(IAdministratorService adminService)
{
_adminService = new AdministratorService(context);
_adminService = adminService;
}

/// <summary>
Expand All @@ -31,31 +32,12 @@ public AdminsController(CCTContext context)
[HttpGet]
[Route("")]
[StateYourBusiness(operation = Operation.READ_ALL, resource = Resource.ADMIN)]
public ActionResult<IEnumerable<ADMIN>> GetAll()
public ActionResult<IEnumerable<AdminViewModel?>> GetAll()
{
var result = _adminService.GetAll();
return Ok(result);
}

/// <summary>
/// Get a specific admin
/// </summary>
/// <returns>
/// The specific admin
/// </returns>
/// <remarks>
/// Server makes call to the database and returns the specific admin
/// </remarks>
// GET api/<controller>/5
[HttpGet]
[Route("{id}")]
[StateYourBusiness(operation = Operation.READ_ONE, resource = Resource.ADMIN)]
public ActionResult<ADMIN> GetByGordonId(string id)
{
var result = _adminService.Get(id);
return Ok(result);
}

/// <summary>Create a new admin to be added to database</summary>
/// <param name="admin">The admin item containing all required and relevant information</param>
/// <returns></returns>
Expand All @@ -64,7 +46,7 @@ public ActionResult<ADMIN> GetByGordonId(string id)
[HttpPost]
[Route("", Name = "Admins")]
[StateYourBusiness(operation = Operation.ADD, resource = Resource.ADMIN)]
public ActionResult<ADMIN> Post([FromBody] ADMIN admin)
public ActionResult<AdminViewModel> Post([FromBody] AdminViewModel admin)
{
var result = _adminService.Add(admin);

Expand All @@ -77,15 +59,15 @@ public ActionResult<ADMIN> Post([FromBody] ADMIN admin)
}

/// <summary>Delete an existing admin</summary>
/// <param name="id">The identifier for the admin to be deleted</param>
/// <param name="username">The username of the user to demote</param>
/// <remarks>Calls the server to make a call and remove the given admin from the database</remarks>
// DELETE api/<controller>/5
[HttpDelete]
[Route("{id}")]
[Route("{username}")]
[StateYourBusiness(operation = Operation.DELETE, resource = Resource.ADMIN)]
public ActionResult<ADMIN> Delete(int id)
public ActionResult<AdminViewModel> Delete(string username)
{
var result = _adminService.Delete(id);
var result = _adminService.Delete(username);

if (result == null)
{
Expand Down
19 changes: 3 additions & 16 deletions Gordon360/Controllers/EmailsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Gordon360.Controllers
[Route("api/[controller]")]
public class EmailsController : GordonControllerBase
{
private readonly EmailService _emailService;
private readonly IEmailService _emailService;

public EmailsController(CCTContext context)
public EmailsController(CCTContext context, IEmailService emailService)
{
_emailService = new EmailService(context);
_emailService = emailService;
}

[HttpGet]
Expand Down Expand Up @@ -54,19 +54,6 @@ public ActionResult SendEmails([FromBody] EmailContentViewModel email)
return Ok();
}

/*
[HttpPut]
[Route("activity/{id}/leaders/session/{session}")]
[StateYourBusiness(operation = Operation.READ_PARTIAL, resource = Resource.EMAILS_BY_LEADERS)]
public IHttpActionResult SendEmailsToleaders(string id, string session, [FromBody] EmailContentViewModel email)
{
var emails = _emailService.GetEmailsForActivityLeaders(id, session);
var toAddress = emails.Select(x => x.Email).ToArray();
_emailService.SendEmails(toAddress, email.FromAddress, email.Subject, email.Content, email.Password);
return Ok();
}
*/

[HttpPut]
[Route("activity/{id}/session/{session}")]
[StateYourBusiness(operation = Operation.READ_PARTIAL, resource = Resource.EMAILS_BY_ACTIVITY)]
Expand Down
18 changes: 4 additions & 14 deletions Gordon360/Controllers/HousingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HousingController(CCTContext context, IProfileService profileService)
_context = context;
_housingService = new HousingService(context);
_accountService = new AccountService(context);
_administratorService = new AdministratorService(context);
_administratorService = new AdministratorService(context, _accountService);
_profileService = profileService;
}

Expand Down Expand Up @@ -207,19 +207,9 @@ public ActionResult<ApartmentApplicationViewModel> GetApartmentApplication(int a
//get token data from context, username is the username of current logged in person
var authenticatedUserUsername = AuthUtils.GetUsername(User);

string userID = _accountService.GetAccountByUsername(authenticatedUserUsername).GordonID;

bool isAdmin = false;

try
{
ADMIN adminModel = _administratorService.Get(userID);
isAdmin = adminModel != null;
}
catch
{
isAdmin = _housingService.CheckIfHousingAdmin(userID);
}
var siteAdmin = _administratorService.GetByUsername(authenticatedUserUsername);
var isHousingAdmin = _housingService.CheckIfHousingAdmin(authenticatedUserUsername);
bool isAdmin = siteAdmin != null || isHousingAdmin;

ApartmentApplicationViewModel result = _housingService.GetApartmentApplication(applicationID, isAdmin);
if (result != null)
Expand Down
Loading