Nullable annotation added
This commit is contained in:
@@ -26,7 +26,7 @@ namespace WD7UVN_HFT_2023241.Logic
|
||||
this.CRUDOperations = CRUDOperations;
|
||||
}
|
||||
|
||||
public IQueryable<Employee> WhoMaintainsService(int serviceId)
|
||||
public IQueryable<Employee>? WhoMaintainsService(int serviceId)
|
||||
{
|
||||
IQueryable<Employee> query =
|
||||
from employee in CRUDOperations.ReadAllEmployees()
|
||||
@@ -34,10 +34,15 @@ namespace WD7UVN_HFT_2023241.Logic
|
||||
where service.ID == serviceId
|
||||
select employee;
|
||||
|
||||
if (query.ToList().Count == 0)
|
||||
{
|
||||
throw new NullReferenceException("No such database entry");
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public Employee WhoIsResponsibleForService(int serviceId)
|
||||
public Employee? WhoIsResponsibleForService(int serviceId)
|
||||
{
|
||||
var query =
|
||||
from service in CRUDOperations.ReadAllServices()
|
||||
@@ -46,28 +51,54 @@ namespace WD7UVN_HFT_2023241.Logic
|
||||
where service.ID == serviceId
|
||||
select employee;
|
||||
|
||||
if (query.ToList().Count == 0)
|
||||
{
|
||||
throw new NullReferenceException("No such database entry");
|
||||
}
|
||||
|
||||
return query.FirstOrDefault();
|
||||
}
|
||||
|
||||
public IQueryable<Employee> WhoWorksInMaintainerTeam(int maintainerTeamId)
|
||||
public IQueryable<Employee>? WhoWorksInMaintainerTeam(int maintainerTeamId)
|
||||
{
|
||||
return CRUDOperations
|
||||
var res = CRUDOperations
|
||||
.ReadAllEmployees()
|
||||
.Where(e => e.MAINTAINER_ID == maintainerTeamId);
|
||||
|
||||
if (res.ToList().Count == 0)
|
||||
{
|
||||
throw new NullReferenceException("No such database entry");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public IQueryable<Employee> GetSubordinates(int managerId)
|
||||
public IQueryable<Employee>? GetSubordinates(int managerId)
|
||||
{
|
||||
return CRUDOperations
|
||||
var res = CRUDOperations
|
||||
.ReadAllEmployees()
|
||||
.Where(e => e.MANAGER_ID == managerId);
|
||||
|
||||
if (res.ToList().Count == 0)
|
||||
{
|
||||
throw new NullReferenceException("No such database entry");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public IQueryable<Customer> WhoUsesService(int serviceId)
|
||||
public IQueryable<Customer>? WhoUsesService(int serviceId)
|
||||
{
|
||||
return CRUDOperations
|
||||
var res = CRUDOperations
|
||||
.ReadAllCustomers()
|
||||
.Where(c => c.SERVICE_ID == serviceId);
|
||||
|
||||
if (res.ToList().Count == 0)
|
||||
{
|
||||
throw new NullReferenceException("No such database entry");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user