Skip to content

Commit

Permalink
Merge pull request #50 from bobbahbrown/net6
Browse files Browse the repository at this point in the history
Version 1.4.0 - NET 6 Upgrade
  • Loading branch information
bobbah authored Jun 25, 2022
2 parents 38d070c + d1b9150 commit da3f64a
Show file tree
Hide file tree
Showing 136 changed files with 5,367 additions and 5,020 deletions.
6 changes: 6 additions & 0 deletions .idea/.idea.CentCom/.idea/misc.xml

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

164 changes: 107 additions & 57 deletions .idea/.idea.CentCom/.idea/workspace.xml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions CentCom.API/CentCom.API.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.3.16</Version>
<TargetFramework>net6.0</TargetFramework>
<Version>1.4.0</Version>
<UserSecretsId>1f5f48fa-862f-4472-ba34-2c5a26035e88</UserSecretsId>
</PropertyGroup>

Expand All @@ -17,14 +17,14 @@
<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449"/>
<PackageReference Include="Enums.NET" Version="4.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.9"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.9"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9"/>
<PackageReference Include="Npgsql" Version="5.0.7"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7"/>
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.5"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.5"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="6.1.5"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.6"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.6"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.6"/>
<PackageReference Include="Npgsql" Version="6.0.5"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.5"/>
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.3.1"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.1"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="6.3.1"/>
</ItemGroup>

<ItemGroup>
Expand Down
113 changes: 56 additions & 57 deletions CentCom.API/Controllers/BanController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,69 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CentCom.API.Controllers
namespace CentCom.API.Controllers;

[Produces("application/json")]
[ApiController]
public class BanController : ControllerBase
{
[Produces("application/json")]
[ApiController]
public class BanController : ControllerBase
{
private readonly IBanService _banService;
private readonly IBanSourceService _banSourceService;
private readonly IBanService _banService;
private readonly IBanSourceService _banSourceService;

public BanController(IBanService banService, IBanSourceService banSourceService)
{
_banService = banService;
_banSourceService = banSourceService;
}
public BanController(IBanService banService, IBanSourceService banSourceService)
{
_banService = banService;
_banSourceService = banSourceService;
}

/// <summary>
/// Retrieves stored bans for a provided ckey.
/// </summary>
/// <param name="key">A BYOND key, will be converted into CKey</param>
/// <param name="onlyActive">Operator for controlling if only active bans will be returned</param>
/// <param name="source">Operator for specifying a specific source to return bans for</param>
/// <returns>A collection of bans matching the provided conditions</returns>
/// <response code="200">The user's bans</response>
/// <response code="400">Key was null or whitespace</response>
[HttpGet("ban/search/{key}")]
[ProducesResponseType(typeof(IEnumerable<BanData>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetBansForKey(string key, [FromQuery] bool onlyActive, [FromQuery] int? source)
/// <summary>
/// Retrieves stored bans for a provided ckey.
/// </summary>
/// <param name="key">A BYOND key, will be converted into CKey</param>
/// <param name="onlyActive">Operator for controlling if only active bans will be returned</param>
/// <param name="source">Operator for specifying a specific source to return bans for</param>
/// <returns>A collection of bans matching the provided conditions</returns>
/// <response code="200">The user's bans</response>
/// <response code="400">Key was null or whitespace</response>
[HttpGet("ban/search/{key}")]
[ProducesResponseType(typeof(IEnumerable<BanData>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetBansForKey(string key, [FromQuery] bool onlyActive, [FromQuery] int? source)
{
if (key == null || string.IsNullOrWhiteSpace(key))
{
if (key == null || string.IsNullOrWhiteSpace(key))
{
return BadRequest("Key cannot be empty or null");
}
return Ok(await _banService.GetBansForKeyAsync(key, source, onlyActive));
return BadRequest("Key cannot be empty or null");
}
return Ok(await _banService.GetBansForKeyAsync(key, source, onlyActive));
}

/// <summary>
/// Lists all available ban sources
/// </summary>
/// <returns>A collection of ban sources</returns>
/// <response code="200">The list of ban sources</response>
[HttpGet("source/list")]
[ProducesResponseType(typeof(IEnumerable<BanSourceData>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetSources()
{
return Ok(await _banSourceService.GetAllBanSourcesAsync());
}
/// <summary>
/// Lists all available ban sources
/// </summary>
/// <returns>A collection of ban sources</returns>
/// <response code="200">The list of ban sources</response>
[HttpGet("source/list")]
[ProducesResponseType(typeof(IEnumerable<BanSourceData>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetSources()
{
return Ok(await _banSourceService.GetAllBanSourcesAsync());
}

/// <summary>
/// Retrieves a specific ban from CentCom using the internal ID
/// </summary>
/// <param name="id">The CentCom Ban ID of the ban</param>
/// <returns>The ban specified</returns>
/// <response code="200">The desired ban</response>
/// <response code="404">Ban ID was invalid</response>
[HttpGet("ban/{id}")]
[ProducesResponseType(typeof(BanData), StatusCodes.Status200OK)]
public async Task<IActionResult> GetBan(int id)
/// <summary>
/// Retrieves a specific ban from CentCom using the internal ID
/// </summary>
/// <param name="id">The CentCom Ban ID of the ban</param>
/// <returns>The ban specified</returns>
/// <response code="200">The desired ban</response>
/// <response code="404">Ban ID was invalid</response>
[HttpGet("ban/{id}")]
[ProducesResponseType(typeof(BanData), StatusCodes.Status200OK)]
public async Task<IActionResult> GetBan(int id)
{
var result = await _banService.GetBanAsync(id);
if (result == null)
{
var result = await _banService.GetBanAsync(id);
if (result == null)
{
return NotFound("Invalid Ban ID");
}
return Ok(result);
return NotFound("Invalid Ban ID");
}
return Ok(result);
}
}
}
17 changes: 8 additions & 9 deletions CentCom.API/Controllers/ScraperInfoController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Microsoft.AspNetCore.Mvc;

namespace CentCom.API.Controllers
namespace CentCom.API.Controllers;

[ApiExplorerSettings(IgnoreApi = true)]
[Route("scraper")]
public class ScraperInfoController : Controller
{
[ApiExplorerSettings(IgnoreApi = true)]
[Route("scraper")]
public class ScraperInfoController : Controller
[HttpGet]
public IActionResult Index()
{
[HttpGet]
public IActionResult Index()
{
return View();
}
return View();
}
}
69 changes: 34 additions & 35 deletions CentCom.API/Controllers/ViewerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,49 @@
using CentCom.Common;
using Microsoft.AspNetCore.Mvc;

namespace CentCom.API.Controllers
namespace CentCom.API.Controllers;

[ApiExplorerSettings(IgnoreApi = true)]
public class ViewerController : Controller
{
[ApiExplorerSettings(IgnoreApi = true)]
public class ViewerController : Controller
private readonly IBanService _banService;

public ViewerController(IBanService banService)
{
private readonly IBanService _banService;
_banService = banService;
}

public ViewerController(IBanService banService)
{
_banService = banService;
}
[HttpGet]
public IActionResult Index()
{
return View();
}

[HttpGet]
public IActionResult Index()
[HttpGet("viewer/search/{key}")]
public async Task<IActionResult> SearchBans(string key)
{
var ckey = KeyUtilities.GetCanonicalKey(key);
if (string.IsNullOrWhiteSpace(ckey) || ckey.Length < 3)
{
return View();
return View("badsearch", new BanSearchViewModel { CKey = ckey });
}

[HttpGet("viewer/search/{key}")]
public async Task<IActionResult> SearchBans(string key)
{
var ckey = KeyUtilities.GetCanonicalKey(key);
if (string.IsNullOrWhiteSpace(ckey) || ckey.Length < 3)
{
return View("badsearch", new BanSearchViewModel() { CKey = ckey });
}
var searchResults = await _banService.SearchSummariesForKeyAsync(key);

var searchResults = await _banService.SearchSummariesForKeyAsync(key);

// If there is only one result, just view it
if (searchResults.Count() == 1)
{
return RedirectToAction("ViewBans", new { key = searchResults.First().CKey });
}

return View(new BanSearchViewModel() { CKey = ckey, Data = searchResults });
// If there is only one result, just view it
if (searchResults.Count() == 1)
{
return RedirectToAction("ViewBans", new { key = searchResults.First().CKey });
}

[HttpGet("viewer/view/{key}")]
public async Task<IActionResult> ViewBans(string key, bool onlyActive = false)
{
var bans = await _banService.GetBansForKeyAsync(key, null, onlyActive);
return View(new BanSearchViewModel { CKey = ckey, Data = searchResults });
}

return View(new BanViewViewModel() { CKey = KeyUtilities.GetCanonicalKey(key), Bans = bans, OnlyActive = onlyActive });
}
[HttpGet("viewer/view/{key}")]
public async Task<IActionResult> ViewBans(string key, bool onlyActive = false)
{
var bans = await _banService.GetBansForKeyAsync(key, null, onlyActive);

return View(new BanViewViewModel { CKey = KeyUtilities.GetCanonicalKey(key), Bans = bans, OnlyActive = onlyActive });
}
}
}
13 changes: 6 additions & 7 deletions CentCom.API/Models/BanSearchViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Collections.Generic;
using CentCom.Common.Models;

namespace CentCom.API.Models
namespace CentCom.API.Models;

public class BanSearchViewModel
{
public class BanSearchViewModel
{
public string CKey { get; set; }
public IEnumerable<KeySummary> Data { get; set; }
}
}
public string CKey { get; set; }
public IEnumerable<KeySummary> Data { get; set; }
}
59 changes: 29 additions & 30 deletions CentCom.API/Models/BanSourceData.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
using CentCom.Common.Models;

namespace CentCom.API.Models
namespace CentCom.API.Models;

/// <summary>
/// DTO for ban sources
/// </summary>
public class BanSourceData
{
/// <summary>
/// DTO for ban sources
/// Internal CentCom DB ID
/// </summary>
public class BanSourceData
{
/// <summary>
/// Internal CentCom DB ID
/// </summary>
public int ID { get; set; }
public int ID { get; set; }

/// <summary>
/// Display name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Display name
/// </summary>
public string Name { get; set; }

/// <summary>
/// The roleplay level of this ban source
/// </summary>
public RoleplayLevel RoleplayLevel { get; set; }
/// <summary>
/// The roleplay level of this ban source
/// </summary>
public RoleplayLevel RoleplayLevel { get; set; }

/// <summary>
/// Generates a DTO from a database BanSource
/// </summary>
/// <param name="source">The object to copy data from</param>
/// <returns>A BanSource DTO</returns>
public static BanSourceData FromBanSource(BanSource source)
/// <summary>
/// Generates a DTO from a database BanSource
/// </summary>
/// <param name="source">The object to copy data from</param>
/// <returns>A BanSource DTO</returns>
public static BanSourceData FromBanSource(BanSource source)
{
return new BanSourceData
{
return new BanSourceData()
{
ID = source.Id,
Name = source.Display,
RoleplayLevel = source.RoleplayLevel
};
}
ID = source.Id,
Name = source.Display,
RoleplayLevel = source.RoleplayLevel
};
}
}
}
15 changes: 7 additions & 8 deletions CentCom.API/Models/BanViewViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using CentCom.Common.Models.DTO;

namespace CentCom.API.Models
namespace CentCom.API.Models;

public class BanViewViewModel
{
public class BanViewViewModel
{
public string CKey { get; set; }
public bool OnlyActive { get; set; }
public IEnumerable<BanData> Bans { get; set; }
}
}
public string CKey { get; set; }
public bool OnlyActive { get; set; }
public IEnumerable<BanData> Bans { get; set; }
}
Loading

0 comments on commit da3f64a

Please sign in to comment.