From 36d462511ff0394e112143e94b26e52ad70aada5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nia=20Vontobel?= Date: Wed, 12 Jul 2023 15:16:31 -0400 Subject: [PATCH] base for editing mail stop of fac, not sure if is changing the right column --- Gordon360/Controllers/ProfilesController.cs | 27 ++++++++++++++++--- Gordon360/Documentation/Gordon360.xml | 21 +++++++++++++++ .../webSQL/Context/efpt.webSQL.config.json | 1 - Gordon360/Models/webSQL/Models/account.cs | 4 +++ .../Models/webSQL/Models/account_profile.cs | 2 +- Gordon360/Services/ProfileService.cs | 5 ++-- Gordon360/Services/ServiceInterfaces.cs | 1 + 7 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Gordon360/Controllers/ProfilesController.cs b/Gordon360/Controllers/ProfilesController.cs index a758ea9cb..76a7fc416 100644 --- a/Gordon360/Controllers/ProfilesController.cs +++ b/Gordon360/Controllers/ProfilesController.cs @@ -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; namespace Gordon360.Controllers { @@ -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; } /// Get profile info of currently logged in user @@ -483,10 +487,10 @@ public async Task> UpdateOfficeHours( /// [HttpPut] [Route("mail_location")] - public async Task> UpdateMailLocation(string value) + public async Task> 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); } @@ -497,7 +501,7 @@ public async Task> UpdateMailLocation /// [HttpPut] [Route("mobile_privacy/{value}")] - public async Task UpdateMobilePrivacyAsync(string value) + public async Task UpdateMobilePrivacyAsync([FromBody]string value) { var authenticatedUserUsername = AuthUtils.GetUsername(User); await _profileService.UpdateMobilePrivacyAsync(authenticatedUserUsername, value); @@ -625,5 +629,20 @@ public ActionResult> GetMembershipHistor return Ok(membershipHistories); } + + /// + /// Return a list of mail destinations' descriptions. + /// + /// All involvements + [HttpGet] + [Route("mail_destinations")] + public ActionResult> GetMailDestinations() + { + var involvements = _webSQLContext.Mailstops.Select(m => m.code) + .Distinct() + .Where(d => d != null) + .OrderBy(d => d); + return Ok(involvements); + } } } diff --git a/Gordon360/Documentation/Gordon360.xml b/Gordon360/Documentation/Gordon360.xml index fb1a8a653..44e45b9ee 100644 --- a/Gordon360/Documentation/Gordon360.xml +++ b/Gordon360/Documentation/Gordon360.xml @@ -680,6 +680,13 @@ office hours + + + Update mail location + + mail location + + Update privacy of mobile phone number @@ -732,6 +739,12 @@ The Student Username The history of that user's membership in involvements + + + Return a list of mail destinations' descriptions. + + All involvements + Gets a list of all Activities by parameter Optional active parameter @@ -2396,6 +2409,14 @@ The new hours to update the user's office hours to updated fac/staff profile if found + + + mail location setting + + The username for the user whose mail location is to be updated + The new mail location to update the user's mail location to + updated fac/staff profile if found + privacy setting user profile photo. diff --git a/Gordon360/Models/webSQL/Context/efpt.webSQL.config.json b/Gordon360/Models/webSQL/Context/efpt.webSQL.config.json index 8678f7562..ce40797a0 100644 --- a/Gordon360/Models/webSQL/Context/efpt.webSQL.config.json +++ b/Gordon360/Models/webSQL/Context/efpt.webSQL.config.json @@ -23,7 +23,6 @@ "salt", "SSN", "barcode", - "mail_server", "account_type", "access_list", "policy", diff --git a/Gordon360/Models/webSQL/Models/account.cs b/Gordon360/Models/webSQL/Models/account.cs index 39448047d..f872c8d81 100644 --- a/Gordon360/Models/webSQL/Models/account.cs +++ b/Gordon360/Models/webSQL/Models/account.cs @@ -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; } /// /// Active Directory Username /// diff --git a/Gordon360/Models/webSQL/Models/account_profile.cs b/Gordon360/Models/webSQL/Models/account_profile.cs index 44db3fb46..46d8c24d3 100644 --- a/Gordon360/Models/webSQL/Models/account_profile.cs +++ b/Gordon360/Models/webSQL/Models/account_profile.cs @@ -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; } } diff --git a/Gordon360/Services/ProfileService.cs b/Gordon360/Services/ProfileService.cs index d552ab343..a27692aef 100644 --- a/Gordon360/Services/ProfileService.cs +++ b/Gordon360/Services/ProfileService.cs @@ -382,9 +382,8 @@ public async Task 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; diff --git a/Gordon360/Services/ServiceInterfaces.cs b/Gordon360/Services/ServiceInterfaces.cs index 0ef35cda1..907cf4ef4 100644 --- a/Gordon360/Services/ServiceInterfaces.cs +++ b/Gordon360/Services/ServiceInterfaces.cs @@ -37,6 +37,7 @@ public interface IProfileService Task UpdateMobilePhoneNumberAsync(string username, string newMobilePhoneNumber); Task UpdateOfficeLocationAsync(string username, string newBuilding, string newRoom); Task UpdateOfficeHoursAsync(string username, string newHours); + Task 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);