Skip to content

Commit

Permalink
Add Options and refactor Dining Service
Browse files Browse the repository at this point in the history
  • Loading branch information
EjPlatzer committed Aug 5, 2024
1 parent 4a6a56f commit d9073e8
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 215 deletions.
4 changes: 2 additions & 2 deletions Gordon360/Controllers/DiningController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public async Task<ActionResult<string>> GetAsync()
var sessionCode = Helpers.GetCurrentSession(context);
var authenticatedUsername = AuthUtils.GetUsername(User);
var authenticatedUserId = int.Parse(accountService.GetAccountByUsername(authenticatedUsername).GordonID);
var diningInfo = diningService.GetDiningPlanInfo(authenticatedUserId, sessionCode);
var diningInfo = await diningService.GetDiningPlanInfoAsync(authenticatedUserId, sessionCode);

if (diningInfo == null)
{
return NotFound();
}
if (diningInfo.ChoiceDescription == "None")
{
var diningBalance = DiningService.GetBalance(authenticatedUserId, FACSTAFF_MEALPLAN_ID);
var diningBalance = await diningService.GetBalanceAsync(authenticatedUserId, FACSTAFF_MEALPLAN_ID);
if (diningBalance == null)
{
return NotFound();
Expand Down
17 changes: 15 additions & 2 deletions Gordon360/Documentation/Gordon360.xml

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

181 changes: 92 additions & 89 deletions Gordon360/Models/ViewModels/ProfileViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,105 +1,108 @@
namespace Gordon360.Models.ViewModels;
using System.Text.Json.Serialization;

public record ProfileViewModel(
namespace Gordon360.Models.ViewModels;

public record ProfileViewModel
{
// All Profiles
string ID,
string Title,
string FirstName,
string MiddleName,
string LastName,
string Suffix,
string MaidenName,
string NickName,
string Email,
string Gender,
string HomeStreet1,
string HomeStreet2,
string HomeCity,
string HomeState,
string HomePostalCode,
string HomeCountry,
string HomePhone,
string HomeFax,
string AD_Username,
int? show_pic,
int? preferred_photo,
string Country,
string Barcode,
string Facebook,
string Twitter,
string Instagram,
string LinkedIn,
string Handshake,
string Calendar,
public string ID { get; set; }
public string Title { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Suffix { get; set; }
public string MaidenName { get; set; }
public string NickName { get; set; }
public string Email { get; set; }
public string Gender { get; set; }
public string HomeStreet1 { get; set; }
public string HomeStreet2 { get; set; }
public string HomeCity { get; set; }
public string HomeState { get; set; }
public string HomePostalCode { get; set; }
public string HomeCountry { get; set; }
public string HomePhone { get; set; }
public string HomeFax { get; set; }
public string AD_Username { get; set; }
public int? show_pic { get; set; }
public int? preferred_photo { get; set; }
public string Country { get; set; }
public string Barcode { get; set; }
public string Facebook { get; set; }
public string Twitter { get; set; }
public string Instagram { get; set; }
public string LinkedIn { get; set; }
public string Handshake { get; set; }
public string Calendar { get; set; }

// Student Only
string OnOffCampus,
string OffCampusStreet1,
string OffCampusStreet2,
string OffCampusCity,
string OffCampusState,
string OffCampusPostalCode,
string OffCampusCountry,
string OffCampusPhone,
string OffCampusFax,
string Major3,
string Major3Description,
string Minor1,
string Minor1Description,
string Minor2,
string Minor2Description,
string Minor3,
string Minor3Description,
string GradDate,
string PlannedGradYear,
string MobilePhone,
bool IsMobilePhonePrivate,
int? ChapelRequired,
int? ChapelAttended,
string Cohort,
string Class,
string AdvisorIDs,
string Married,
string Commuter,
public string OnOffCampus { get; set; }
public string OffCampusStreet1 { get; set; }
public string OffCampusStreet2 { get; set; }
public string OffCampusCity { get; set; }
public string OffCampusState { get; set; }
public string OffCampusPostalCode { get; set; }
public string OffCampusCountry { get; set; }
public string OffCampusPhone { get; set; }
public string OffCampusFax { get; set; }
public string Major3 { get; set; }
public string Major3Description { get; set; }
public string Minor1 { get; set; }
public string Minor1Description { get; set; }
public string Minor2 { get; set; }
public string Minor2Description { get; set; }
public string Minor3 { get; set; }
public string Minor3Description { get; set; }
public string GradDate { get; set; }
public string PlannedGradYear { get; set; }
public string MobilePhone { get; set; }
public bool IsMobilePhonePrivate { get; set; }
public int? ChapelRequired { get; set; }
public int? ChapelAttended { get; set; }
public string Cohort { get; set; }
public string Class { get; set; }
public string AdvisorIDs { get; set; }
public string Married { get; set; }
public string Commuter { get; set; }

// Alumni Only
string? WebUpdate,
string HomeEmail,
string MaritalStatus,
string College,
string ClassYear,
string? PreferredClassYear,
string ShareName,
string? ShareAddress,
public int? WebUpdate { get; set; }
public string HomeEmail { get; set; }
public string MaritalStatus { get; set; }
public string College { get; set; }
public string ClassYear { get; set; }
public string? PreferredClassYear { get; set; }
public string ShareName { get; set; }
public string? ShareAddress { get; set; }

// Student And Alumni Only
string Major,
string Major1Description,
string Major2,
string Major2Description,
string grad_student,
public string Major { get; set; }
public string Major1Description { get; set; }
public string Major2 { get; set; }
public string Major2Description { get; set; }
public string grad_student { get; set; }

// FacStaff Only
string? OnCampusDepartment,
string? Type,
string? office_hours,
string Dept,
string Mail_Description,
public string? OnCampusDepartment { get; set; }
public string? Type { get; set; }
public string? office_hours { get; set; }
public string Dept { get; set; }
public string Mail_Description { get; set; }

// FacStaff and Alumni Only
string JobTitle,
string SpouseName,
public string JobTitle { get; set; }
public string SpouseName { get; set; }

// FacStaff and Student Only
string BuildingDescription,
string Mail_Location,
string OnCampusBuilding,
string OnCampusRoom,
string OnCampusPhone,
string OnCampusPrivatePhone,
string OnCampusFax,
string KeepPrivate,
public string BuildingDescription { get; set; }
public string Mail_Location { get; set; }
public string OnCampusBuilding { get; set; }
public string OnCampusRoom { get; set; }
public string OnCampusPhone { get; set; }
public string OnCampusPrivatePhone { get; set; }
public string OnCampusFax { get; set; }
public string KeepPrivate { get; set; }

// ProfileViewModel Only
string PersonType
);
public string PersonType { get; set; }
}
19 changes: 19 additions & 0 deletions Gordon360/Options/BonAppetitOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Extensions.Options;
using System.ComponentModel.DataAnnotations;

namespace Gordon360.Options;

public sealed record BonAppetitOptions
{
public const string BonAppetit = "BonAppetit";

[Required]
public required string IssuerID { get; set; }
[Required]
public required string ApplicationID { get; set; }
[Required]
public required string Secret { get; set; }
}

[OptionsValidator]
public partial class ValidateBonAppetitOptions : IValidateOptions<BonAppetitOptions> { }
18 changes: 18 additions & 0 deletions Gordon360/Options/OptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

namespace Gordon360.Options;

public static class OptionsExtensions
{
public static IServiceCollection Add360Options(this IServiceCollection services)
{
services.AddSingleton<IValidateOptions<BonAppetitOptions>, ValidateBonAppetitOptions>();
services.AddOptions<BonAppetitOptions>()
.BindConfiguration(BonAppetitOptions.BonAppetit)
.ValidateOnStart();

return services;
}
}
3 changes: 2 additions & 1 deletion Gordon360/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Gordon360.Models.CCT.Context;
using Gordon360.Models.MyGordon.Context;
using Gordon360.Models.webSQL.Context;
using Gordon360.Options;
using Gordon360.Services;
using Gordon360.Utilities;
using Microsoft.AspNetCore.Builder;
Expand All @@ -13,7 +14,6 @@
using Microsoft.Identity.Web;
using Microsoft.OpenApi.Models;
using Serilog;
using Serilog.Formatting.Compact;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -92,6 +92,7 @@
options.UseSqlServer(builder.Configuration.GetConnectionString("webSQL"))
);

builder.Services.Add360Options();
builder.Services.Add360Services();
builder.Services.AddHostedService<EventCacheRefreshService>();
builder.Services.AddScoped<ServerUtils, ServerUtils>();
Expand Down
2 changes: 1 addition & 1 deletion Gordon360/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sqlDebugging": true,
"applicationUrl": "https://localhost:51627;http://localhost:51626"
"applicationUrl": "https://localhost:51627;http://172.26.160.1:51626"
},
"Train": {
"commandName": "Project",
Expand Down
Loading

0 comments on commit d9073e8

Please sign in to comment.