Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion test/RAPS/RAPSControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task RolePermissions_ReturnsView_ForValidRoleId()
using var context = await CreateContextAsync(connection);
var controller = CreateController(context);

var result = await controller.RolePermissions(5);
var result = controller.RolePermissions(5);

var view = Assert.IsType<ViewResult>(result);
Assert.Equal(5, view.ViewData["roleId"]);
Expand Down Expand Up @@ -215,6 +215,11 @@ public async Task GroupSync_RunsSyncInItsOwnScope_WhenGroupExists()
scope.Received(1).Dispose();
}

private static Task AssertBadRequestForInvalidModelStateAsync(Func<RAPSController, IActionResult> action)
{
return AssertBadRequestForInvalidModelStateAsync(c => Task.FromResult(action(c)));
}

private static async Task AssertBadRequestForInvalidModelStateAsync(Func<RAPSController, Task<IActionResult>> action)
{
using var connection = await OpenConnectionAsync();
Expand Down
14 changes: 7 additions & 7 deletions web/Areas/Directory/Controllers/DirectoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ public DirectoryController(AAUDContext aaud, RAPSContext rapsContext)
/// Directory home page
/// </summary>
[Route("")]
public async Task<ActionResult> Index(string? useExample)
public ActionResult Index(string? useExample)
{
return await Task.Run(() => View("~/Areas/Directory/Views/Card.cshtml"));
return View("~/Areas/Directory/Views/Card.cshtml");
}

/// <summary>
/// Directory home page
/// </summary>
[Route("nav")]
public async Task<ActionResult<IEnumerable<NavMenuItem>>> Nav()
public ActionResult<IEnumerable<NavMenuItem>> Nav()
{
var nav = new List<NavMenuItem>();
return await Task.Run(() => nav);
return nav;
}


Expand Down Expand Up @@ -105,12 +105,12 @@ public async Task<ActionResult<IEnumerable<IndividualSearchResult>>> GetUCD(stri
/// <summary>
/// Directory results
/// </summary>
/// <param name="uid">User ID</param>
/// <param name="mothraID">Mothra ID</param>
[Route("userInfo/{mothraID}")]
public async Task<IActionResult> DirectoryResult(string mothraID)
public IActionResult DirectoryResult(string mothraID)
{
// pull in the user based on uid
return await Task.Run(() => View("~/Areas/Directory/Views/UserInfo.cshtml"));
return View("~/Areas/Directory/Views/UserInfo.cshtml");
}

/// <summary>
Expand Down
123 changes: 61 additions & 62 deletions web/Areas/RAPS/Controllers/RAPSController.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions web/Areas/Students/Services/PhotoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public async Task<bool> StudentPhotoExistsAsync(string mailId)
return false;
}

// Legitimate Task.Run: File.Exists is blocking I/O (photo store may be a
// network share) and callers fan these checks out with Task.WhenAll.
return await Task.Run(() =>
{
var photoPath = GetPhotoPath(mailId);
Expand Down
2 changes: 2 additions & 0 deletions web/Classes/HealthChecks/LdapHealthCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public async Task<HealthCheckResult> CheckHealthAsync(

try
{
// Legitimate Task.Run: S.DS.Protocols has no async API, so the
// blocking LDAP bind is offloaded to keep the caller responsive.
await Task.Run(() =>
{
var ldapIdentifier = new LdapDirectoryIdentifier(_ldapServer, _ldapSSLPort);
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/CMSBlocks/CMSBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public CMSBlocksViewComponent(VIPERContext viperContext, RAPSContext rapsContext
CMS = new CMS(viperContext, rapsContext, sanitizerService);
}

public async Task<IViewComponentResult> InvokeAsync(int? contentBlockID, string? friendlyName, string? system, string? viperSectionPath, string? page, int? blockOrder, bool? allowPublicAccess, int? status)
public IViewComponentResult Invoke(int? contentBlockID, string? friendlyName, string? system, string? viperSectionPath, string? page, int? blockOrder, bool? allowPublicAccess, int? status)
{
List<ContentBlock>? blocks = CMS.GetContentBlocksAllowed(contentBlockID, friendlyName, system, viperSectionPath, page, blockOrder, allowPublicAccess, status)?.ToList();

return await Task.Run(() => View("Default", blocks));
return View("Default", blocks);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace Viper.Views.Shared.Components.EmulationBanner
[ViewComponent(Name = "EmulationBanner")]
public class EmulationBannerViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
public IViewComponentResult Invoke()
{
IUserHelper UserHelper = new UserHelper();
if (!UserHelper.IsEmulating())
{
return await Task.Run(() => (IViewComponentResult)Content(string.Empty));
return Content(string.Empty);
}

string? displayFullName = UserHelper.GetCurrentUser()?.DisplayFullName;
return await Task.Run(() => View("Default", displayFullName));
return View("Default", displayFullName);
}
}
}
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/LeftNav/LeftNav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace Viper.Views.Shared.Components.LeftNav
[ViewComponent(Name = "LeftNav")]
public class LeftNavViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(AaudUser user, int nav)
public IViewComponentResult Invoke(AaudUser user, int nav)
{



return await Task.Run(() => View("Default", user));
return View("Default", user);
}

}
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/MainNav/MainNav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public MainNavViewComponent(RAPSContext context)
_context = context;
}

public async Task<IViewComponentResult> InvokeAsync(AaudUser user)
public IViewComponentResult Invoke(AaudUser user)
{
ViewData["OldViperURL"] = oldViperURL;
var userHelper = new UserHelper();
Expand All @@ -67,7 +67,7 @@ public async Task<IViewComponentResult> InvokeAsync(AaudUser user)
"scheduler" => "Computing",
_ => "VIPER Home",
};
return await Task.Run(() => View("Default", user));
return View("Default", user);
}

}
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/MiniNav/MiniNav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class MiniNavViewComponent : ViewComponent
{
private readonly string oldViperURL = HttpHelper.GetOldViperRootURL();

public async Task<IViewComponentResult> InvokeAsync(AaudUser user)
public IViewComponentResult Invoke(AaudUser user)
{
ViewData["OldViperURL"] = oldViperURL;
return await Task.Run(() => View("Default", user));
return View("Default", user);
}

}
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/ProfilePic/ProfilePic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public ProfilePicViewComponent(AAUDContext context)
_AAUDContext = context;
}

public async Task<IViewComponentResult> InvokeAsync(string? userName)
public IViewComponentResult Invoke(string? userName)
{
IUserHelper UserHelper = new UserHelper();
AaudUser? user = UserHelper.GetByLoginId(_AAUDContext, userName);

return await Task.Run(() => View("Default", user));
return View("Default", user);
Comment thread
rlorenzo marked this conversation as resolved.
}

}
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/SessionTimeout/SessionTimeout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Viper.Views.Shared.Components.SessionTimeout
[ViewComponent(Name = "SessionTimeout")]
public class SessionTimeout : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
public IViewComponentResult Invoke()
{
UserHelper userHelper = new UserHelper();
string? loginId = userHelper.GetCurrentUser()?.LoginId;
Expand All @@ -14,7 +14,7 @@ public async Task<IViewComponentResult> InvokeAsync()
+ "/public/timeout/seconds_until_timeout_v2.cfm?id="
+ (loginId ?? "")
+ "&service=" + (onDev ? "Viper2-dev" : "Viper2");
return await Task.Run(() => View("Default"));
return View("Default");
}

}
Expand Down
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/VueCdn/VueCdnCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Viper.Views.Shared.Components.VueCdn
[ViewComponent(Name = "VueCdnCreate")]
public class VueCdnCreate : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
public IViewComponentResult Invoke()
{
return await Task.Run(() => View("~/Views/Shared/Components/VueCdn/VueCdnCreate.cshtml"));
return View("~/Views/Shared/Components/VueCdn/VueCdnCreate.cshtml");
}
}
}
4 changes: 2 additions & 2 deletions web/Views/Shared/Components/VueCdn/VueCdnInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Viper.Views.Shared.Components.VueCdn
[ViewComponent(Name = "VueCdnInit")]
public class VueCdnInit : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
public IViewComponentResult Invoke()
{
return await Task.Run(() => View("~/Views/Shared/Components/VueCdn/VueCdnInit.cshtml"));
return View("~/Views/Shared/Components/VueCdn/VueCdnInit.cshtml");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Viper.Views.Shared.Components.VueTableDefault

public class VueTableDefaultViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(IEnumerable<Object>? data, string keyColumnName,
public IViewComponentResult Invoke(IEnumerable<Object>? data, string keyColumnName,
IEnumerable<string>? skipColumns = null, IEnumerable<Tuple<string, string>>? altColumnNames = null,
IEnumerable<string>? skipColumnsVisible = null
)
Expand All @@ -25,7 +25,7 @@ public async Task<IViewComponentResult> InvokeAsync(IEnumerable<Object>? data, s
ViewData["Rows"] = GetDefaultRows(dataList, skipList);
ViewData["VisibleColumns"] = GetDefaultVisibleColumns(dataList, skipVisibleList);

return await Task.Run(() => View("Default"));
return View("Default");
}

#region public static string GetDefaultColumnNames(IEnumerable<Object>? data, IEnumerable<string>? skipColumns = null, IEnumerable<Tuple<string,string>>? altColumnNames = null)
Expand Down
Loading