diff --git a/Gordon360/Services/ProfileService.cs b/Gordon360/Services/ProfileService.cs index 09737525e..130bd0985 100644 --- a/Gordon360/Services/ProfileService.cs +++ b/Gordon360/Services/ProfileService.cs @@ -16,6 +16,9 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Gordon360.Enums; +using System.Security.Permissions; +using Microsoft.AspNetCore.Authentication.Negotiate; +using Microsoft.Extensions.ObjectPool; namespace Gordon360.Services; @@ -380,6 +383,31 @@ public async Task UpdateUserPrivacyAsync(string username, UserPrivacyUpdateViewM { user.Visibility = userPrivacy.VisibilityGroup; } + + // Attempt to update the "isMobilePhonePrivate" profile field. + // Students have this but facstaff and alumni do not. This + // maintains some measure of backward-compatibility in that + // changes made on 360 are pushed to Jenzebar, but changes made + // to this profile setting in other places will not make it + // into 360. + try + { + if (user is not null && field == "MobilePhone") + { + var value = user.Visibility == "Public" ? "N" : "Y"; + await context.Procedures.UPDATE_PHONE_PRIVACYAsync(int.Parse(account.GordonID), value); + // Update value in cached data + var student = context.Student.FirstOrDefault(x => x.ID == account.GordonID); + if (student != null) + { + student.IsMobilePhonePrivate = value == "Y" ? 1 : 0; + } + } + } + catch (Exception e) + { + System.Diagnostics.Debug.WriteLine(e.Message); + } } context.SaveChanges();