Skip to content

Commit

Permalink
Merge pull request #228 from bcgov/SCJ-250
Browse files Browse the repository at this point in the history
SCJ-250: Allow leading zeros on case numbers
  • Loading branch information
molund authored Aug 27, 2024
2 parents c400146 + 57ce2e9 commit ed6b3ea
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 20 deletions.
9 changes: 7 additions & 2 deletions app/Controllers/ScBookingController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -65,10 +66,14 @@ public async Task<IActionResult> Search(ScCaseSearchViewModel model)
);
}

if (!model.CaseNumber.HasValue)
if (string.IsNullOrWhiteSpace(model.CaseNumber))
{
ModelState.AddModelError("CaseNumber", "Please provide a Court File Number");
}
else if (!model.CaseNumber.All(char.IsDigit))
{
ModelState.AddModelError("CaseNumber", "Invalid number");
}

model.CaseLocationName = await _scCoreService.GetLocationNameAsync(
model.CaseRegistryId
Expand Down Expand Up @@ -197,7 +202,7 @@ public async Task<IActionResult> AvailableTimesAsync()
{
var model = await _scCoreService.LoadAvailableTimesFormAsync();

if (model.CaseNumber == 0)
if (string.IsNullOrWhiteSpace(model.CaseNumber))
{
return RedirectToAction("Index");
}
Expand Down
3 changes: 1 addition & 2 deletions app/Services/SC/ScCoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class ScCoreService

//Constructor
public ScCoreService(
ApplicationDbContext dbContext,
IConfiguration configuration,
SessionService sessionService,
ScCacheService scCacheService
Expand Down Expand Up @@ -93,7 +92,7 @@ public async Task<ScCaseSearchViewModel> GetSearchResults(ScCaseSearchViewModel
{
_session.ScBookingInfo = new ScSessionBookingInfo
{
CaseNumber = model.CaseNumber.GetValueOrDefault(0),
CaseNumber = model.CaseNumber,
LocationPrefix = newModel.LocationPrefix,
CaseSearchResults = newModel.CaseSearchResults,
CaseRegistryId = model.CaseRegistryId,
Expand Down
2 changes: 1 addition & 1 deletion app/Utils/ScSessionBookingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SCJ.Booking.MVC.Utils
public class ScSessionBookingInfo
{
public int PhysicalFileId { get; set; }
public int CaseNumber { get; set; }
public string CaseNumber { get; set; }
public string FullCaseNumber { get; set; }
public string LocationPrefix { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions app/ViewModels/SC/ScAvailableTimesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ScAvailableTimesViewModel()
ConferenceLocationRegistryId = -1;
ContainerId = -1;
SelectedConferenceDate = string.Empty;
CaseNumber = 0;
CaseNumber = string.Empty;
HearingTypeId = -1;
TrialFormulaType = string.Empty;
AvailableRegularTrialDates = new List<DateTime> { };
Expand All @@ -31,7 +31,7 @@ public ScAvailableTimesViewModel()
}

//Search fields
public int CaseNumber { get; set; }
public string CaseNumber { get; set; }
public int HearingTypeId { get; set; }
public string TrialFormulaType { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion app/ViewModels/SC/ScCaseSearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ScCaseSearchViewModel()

//Search fields
[Display(Name = "Action Number")]
public int? CaseNumber { get; set; }
public string CaseNumber { get; set; }

// Selected Registry ID
[Required(ErrorMessage = "Please select the registry where the file was created.")]
Expand Down
Loading

0 comments on commit ed6b3ea

Please sign in to comment.