Skip to content

Commit

Permalink
Uniemożliwienie przypisania jednego kierownika do wielu działów.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszdudkowski committed Jan 14, 2021
1 parent a18c996 commit 223faaf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions monday/Controllers/DepartmentsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public async Task<IActionResult> Create([Bind("DepartmentID,DepartmentName,Depar
{
if (ModelState.IsValid)
{
bool isDepartmentManagerInDB = _context.Departments.Where(d => d.DepartmentManagerID == department.DepartmentManagerID).Any();
if(isDepartmentManagerInDB == true)
{
return RedirectToAction("Error", "Home");
}
_context.Add(department);
await _context.SaveChangesAsync();
var employeeManager = _context.Employees.Where(e => e.DepartmentManager.DepartmentManagerID == department.DepartmentManagerID).Single();
Expand Down

0 comments on commit 223faaf

Please sign in to comment.