Skip to content

Commit

Permalink
base for editing mail stop of fac, not sure if is changing the right …
Browse files Browse the repository at this point in the history
…column
  • Loading branch information
antoniavonto committed Jul 12, 2023
1 parent b96b8b3 commit 36d4625
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 9 deletions.
27 changes: 23 additions & 4 deletions Gordon360/Controllers/ProfilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;
using Gordon360.Models.webSQL.Context;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Gordon360.Models.webSQL.Context;

Check warning on line 21 in Gordon360/Controllers/ProfilesController.cs

View workflow job for this annotation

GitHub Actions / build

The using directive for 'Gordon360.Models.webSQL.Context' appeared previously in this namespace

namespace Gordon360.Controllers
{
Expand All @@ -27,13 +29,15 @@ public class ProfilesController : GordonControllerBase
private readonly IAccountService _accountService;
private readonly IMembershipService _membershipService;
private readonly IConfiguration _config;
private readonly webSQLContext _webSQLContext;

public ProfilesController(IProfileService profileService, IAccountService accountService, IMembershipService membershipService, IConfiguration config)
public ProfilesController(IProfileService profileService, IAccountService accountService, IMembershipService membershipService, IConfiguration config, webSQLContext webSQLContext)
{
_profileService = profileService;
_accountService = accountService;
_membershipService = membershipService;
_config = config;
_webSQLContext = webSQLContext;
}

/// <summary>Get profile info of currently logged in user</summary>
Expand Down Expand Up @@ -483,10 +487,10 @@ public async Task<ActionResult<FacultyStaffProfileViewModel>> UpdateOfficeHours(
/// <returns></returns>
[HttpPut]
[Route("mail_location")]
public async Task<ActionResult<FacultyStaffProfileViewModel>> UpdateMailLocation(string value)
public async Task<ActionResult<FacultyStaffProfileViewModel>> UpdateMailLocation([FromBody]string value)
{
var username = AuthUtils.GetUsername(User);
var result = await _profileService.UpdateOfficeHoursAsync(username, value);
var result = await _profileService.UpdateMailLocationAsync(username, value);
return Ok(result);
}

Expand All @@ -497,7 +501,7 @@ public async Task<ActionResult<FacultyStaffProfileViewModel>> UpdateMailLocation
/// <returns></returns>
[HttpPut]
[Route("mobile_privacy/{value}")]
public async Task<ActionResult> UpdateMobilePrivacyAsync(string value)
public async Task<ActionResult> UpdateMobilePrivacyAsync([FromBody]string value)
{
var authenticatedUserUsername = AuthUtils.GetUsername(User);
await _profileService.UpdateMobilePrivacyAsync(authenticatedUserUsername, value);
Expand Down Expand Up @@ -625,5 +629,20 @@ public ActionResult<IEnumerable<MembershipHistoryViewModel>> GetMembershipHistor

return Ok(membershipHistories);
}

/// <summary>
/// Return a list of mail destinations' descriptions.
/// </summary>
/// <returns> All involvements</returns>
[HttpGet]
[Route("mail_destinations")]
public ActionResult<IEnumerable<string>> GetMailDestinations()
{
var involvements = _webSQLContext.Mailstops.Select(m => m.code)
.Distinct()
.Where(d => d != null)
.OrderBy(d => d);
return Ok(involvements);
}
}
}
21 changes: 21 additions & 0 deletions Gordon360/Documentation/Gordon360.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Gordon360/Models/webSQL/Context/efpt.webSQL.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"salt",
"SSN",
"barcode",
"mail_server",
"account_type",
"access_list",
"policy",
Expand Down
4 changes: 4 additions & 0 deletions Gordon360/Models/webSQL/Models/account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
namespace Gordon360.Models.webSQL.Models
{
[Table("account")]
[Index("mail_server", Name = "IX_account_mail_server")]
public partial class account
{
[Key]
public int account_id { get; set; }
[StringLength(20)]
[Unicode(false)]
public string mail_server { get; set; }
/// <summary>
/// Active Directory Username
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Gordon360/Models/webSQL/Models/account_profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class account_profile
{
[Key]
public int account_id { get; set; }
[StringLength(75)]
[StringLength(8000)]
[Unicode(false)]
public string office_hours { get; set; }
}
Expand Down
5 changes: 2 additions & 3 deletions Gordon360/Services/ProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,8 @@ public async Task<FacultyStaffProfileViewModel> UpdateMailLocationAsync(string u
{
throw new ResourceNotFoundException() { ExceptionMessage = "The account was not found" };
}
var acccount = _webSQLContext.accounts.FirstOrDefault(a => a.AD_Username == username);
var user = _webSQLContext.account_profiles.FirstOrDefault(a => a.account_id == acccount.account_id);
user.office_hours = newHours;
var user = _webSQLContext.accounts.FirstOrDefault(a => a.AD_Username == username);
user.mail_server = newMail;
await _webSQLContext.SaveChangesAsync();

return profile;
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public interface IProfileService
Task<StudentProfileViewModel> UpdateMobilePhoneNumberAsync(string username, string newMobilePhoneNumber);
Task<FacultyStaffProfileViewModel> UpdateOfficeLocationAsync(string username, string newBuilding, string newRoom);
Task<FacultyStaffProfileViewModel> UpdateOfficeHoursAsync(string username, string newHours);
Task<FacultyStaffProfileViewModel> UpdateMailLocationAsync(string username, string newMail);
Task UpdateMobilePrivacyAsync(string username, string value);
Task UpdateImagePrivacyAsync(string username, string value);
Task UpdateProfileImageAsync(string username, string path, string name);
Expand Down

0 comments on commit 36d4625

Please sign in to comment.