public IActionResult OnGet(int? id) { DepartmentVM = new DeptViewModel() { Faculty = _facultyRepo.GetFacultyListOfDropDown(), Department = new Department() }; if (id != null) { var deptFromDb = _deptRepo.GetFisrtOrDefault(m => m.Id == id); if (deptFromDb == null) { return NotFound(); } DepartmentVM.Department = deptFromDb; } return Page(); }