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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace WD7UVN_HFT_2023241.Repository
|
||||
Database.Context.SaveChanges();
|
||||
}
|
||||
|
||||
public Employee ReadEmployee(int employeeId)
|
||||
public Employee? ReadEmployee(int employeeId)
|
||||
{
|
||||
return Database.Context.Employees.Find(employeeId);
|
||||
}
|
||||
|
||||
public IQueryable<Employee> ReadAllEmployees()
|
||||
public IQueryable<Employee>? ReadAllEmployees()
|
||||
{
|
||||
return Database.Context.Employees.AsQueryable();
|
||||
}
|
||||
@@ -88,12 +88,12 @@ namespace WD7UVN_HFT_2023241.Repository
|
||||
Database.Context.SaveChanges();
|
||||
}
|
||||
|
||||
public Service ReadService(int serviceId)
|
||||
public Service? ReadService(int serviceId)
|
||||
{
|
||||
return Database.Context.Services.Find(serviceId);
|
||||
}
|
||||
|
||||
public IQueryable<Service> ReadAllServices()
|
||||
public IQueryable<Service>? ReadAllServices()
|
||||
{
|
||||
return Database.Context.Services.AsQueryable();
|
||||
}
|
||||
@@ -124,12 +124,12 @@ namespace WD7UVN_HFT_2023241.Repository
|
||||
Database.Context.SaveChanges();
|
||||
}
|
||||
|
||||
public MaintainerTeam ReadMaintainerTeam(int maintainerTeamId)
|
||||
public MaintainerTeam? ReadMaintainerTeam(int maintainerTeamId)
|
||||
{
|
||||
return Database.Context.Maintainers.Find(maintainerTeamId);
|
||||
}
|
||||
|
||||
public IQueryable<MaintainerTeam> ReadAllMaintainerTeams()
|
||||
public IQueryable<MaintainerTeam>? ReadAllMaintainerTeams()
|
||||
{
|
||||
return Database.Context.Maintainers.AsQueryable();
|
||||
}
|
||||
@@ -160,12 +160,12 @@ namespace WD7UVN_HFT_2023241.Repository
|
||||
Database.Context.SaveChanges();
|
||||
}
|
||||
|
||||
public Customer ReadCustomer(int customerId)
|
||||
public Customer? ReadCustomer(int customerId)
|
||||
{
|
||||
return Database.Context.Customers.Find(customerId);
|
||||
}
|
||||
|
||||
public IQueryable<Customer> ReadAllCustomers()
|
||||
public IQueryable<Customer>? ReadAllCustomers()
|
||||
{
|
||||
return Database.Context.Customers.AsQueryable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user