Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#313 Missing validation check #325

Merged
merged 4 commits into from
Aug 25, 2024
Merged
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
53 changes: 41 additions & 12 deletions PC2/Controllers/AboutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public IActionResult CreateStaff()
[HttpPost]
public async Task<IActionResult> CreateStaff(Staff staff)
{
await StaffDB.AddStaff(_context, staff);
return RedirectToAction("IndexStaff");
if (ModelState.IsValid)
{
await StaffDB.AddStaff(_context, staff);
return RedirectToAction("IndexStaff");
}
return View(staff);
}

/// <summary>
Expand All @@ -56,8 +60,13 @@ public async Task<IActionResult> EditStaff(int id)
[HttpPost]
public async Task<IActionResult> EditStaff(Staff staff)
{
await StaffDB.SaveChanges(_context, staff);
return RedirectToAction("IndexStaff");
if (ModelState.IsValid)
{
await StaffDB.SaveChanges(_context, staff);
return RedirectToAction("IndexStaff");
}

return View(staff);
}

/// <summary>
Expand Down Expand Up @@ -105,8 +114,13 @@ public IActionResult CreateBoard()
[HttpPost]
public async Task<IActionResult> CreateBoard(Board board)
{
await BoardDB.CreateBoardMember(_context, board);
return RedirectToAction("IndexBoard");
if (ModelState.IsValid)
{
await BoardDB.CreateBoardMember(_context, board);
return RedirectToAction("IndexBoard");
}

return View(board);
}

/// <summary>
Expand All @@ -123,8 +137,13 @@ public async Task<IActionResult> EditBoard(int id)
[HttpPost]
public async Task<IActionResult> EditBoard(Board board)
{
await BoardDB.EditBoardMember(_context, board);
return RedirectToAction("IndexBoard");
if (ModelState.IsValid)
{
await BoardDB.EditBoardMember(_context, board);
return RedirectToAction("IndexBoard");
}

return View(board);
}

/// <summary>
Expand Down Expand Up @@ -172,8 +191,13 @@ public IActionResult CreateSteeringCommittee()
[HttpPost]
public async Task<IActionResult> CreateSteeringCommittee(SteeringCommittee steeringCommittee)
{
await SteeringCommitteeDB.Create(_context, steeringCommittee);
return RedirectToAction("IndexSteeringCommittee");
if (ModelState.IsValid)
{
await SteeringCommitteeDB.Create(_context, steeringCommittee);
return RedirectToAction("IndexSteeringCommittee");
}

return View(steeringCommittee);
}

/// <summary>
Expand All @@ -190,8 +214,13 @@ public async Task<IActionResult> EditSteeringCommittee(int id)
[HttpPost]
public async Task<IActionResult> EditSteeringCommittee(SteeringCommittee steeringCommittee)
{
await SteeringCommitteeDB.EditSteeringCommittee(_context, steeringCommittee);
return RedirectToAction("IndexSteeringCommittee");
if (ModelState.IsValid)
{
await SteeringCommitteeDB.EditSteeringCommittee(_context, steeringCommittee);
return RedirectToAction("IndexSteeringCommittee");
}

return View(steeringCommittee);
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions PC2/Models/People.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// <summary>
/// The persons full name
/// </summary>
public string Name { get; set; }

Check warning on line 16 in PC2/Models/People.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

/// <summary>
/// Position title
Expand All @@ -34,6 +34,7 @@
{
/// <summary>
/// The staff/person's phone number.
/// Note: Not every staff member has a phone number.
/// </summary>
public string? Phone { get; set; }

Expand All @@ -45,6 +46,8 @@
/// <summary>
/// The staff/person's email address.
/// </summary>
[DataType(DataType.EmailAddress)]
[EmailAddress]
public required string Email { get; set; }

/// <summary>
Expand Down
Loading