Exception handling
This commit is contained in:
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
using System;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
{
|
||||
@@ -17,16 +18,30 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Customer> ReadAllCustomers()
|
||||
public IQueryable<Customer>? ReadAllCustomers()
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadAllCustomers();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public Customer ReadCustomer(int id)
|
||||
public Customer? ReadCustomer(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadCustomer(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut()]
|
||||
public void PutCustomer([FromBody] Customer e)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
@@ -17,16 +18,30 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Employee> ReadAllEmployees()
|
||||
public IQueryable<Employee>? ReadAllEmployees()
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadAllEmployees();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public Employee ReadEmployee(int id)
|
||||
public Employee? ReadEmployee(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadEmployee(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut()]
|
||||
public void PutEmployee([FromBody] Employee e)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
@@ -17,16 +18,30 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<MaintainerTeam> ReadAllMaintainerTeams()
|
||||
public IQueryable<MaintainerTeam>? ReadAllMaintainerTeams()
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadAllMaintainerTeams();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public MaintainerTeam ReadMaintainerTeam(int id)
|
||||
public MaintainerTeam? ReadMaintainerTeam(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadMaintainerTeam(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut()]
|
||||
public void PutMaintainerTeam([FromBody] MaintainerTeam e)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
@@ -17,16 +18,30 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Service> ReadAllServices()
|
||||
public IQueryable<Service>? ReadAllServices()
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadAllServices();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public Service ReadService(int id)
|
||||
public Service? ReadService(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.CRUDOperations.ReadService(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut()]
|
||||
public void PutService([FromBody] Service e)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
@@ -17,9 +18,16 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Employee> GetSubordinates([FromQuery] int id)
|
||||
public IQueryable<Employee>? GetSubordinates([FromQuery] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.GetSubordinates(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
@@ -17,9 +17,16 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public Employee WhoIsResponsibleForService([FromQuery] int id)
|
||||
public Employee? WhoIsResponsibleForService([FromQuery] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.WhoIsResponsibleForService(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
@@ -17,9 +18,16 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Employee> WhoUsesService([FromQuery] int id)
|
||||
public IQueryable<Employee>? WhoUsesService([FromQuery] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.WhoMaintainsService(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
@@ -17,9 +18,16 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Customer> WhoUsesService([FromQuery] int id)
|
||||
public IQueryable<Customer>? WhoUsesService([FromQuery] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.WhoUsesService(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WD7UVN_HFT_2023241.Logic;
|
||||
using System.Linq;
|
||||
using WD7UVN_HFT_2023241.Models;
|
||||
using Microsoft.AspNetCore.Mvc.Diagnostics;
|
||||
|
||||
namespace WD7UVN_HFT_2023241.Endpoint
|
||||
{
|
||||
@@ -17,9 +19,16 @@ namespace WD7UVN_HFT_2023241.Endpoint
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public IQueryable<Employee> WhoWorksInMaintainerTeam([FromQuery] int id)
|
||||
public IQueryable<Employee>? WhoWorksInMaintainerTeam([FromQuery] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return LogicServices.WhoWorksInMaintainerTeam(id);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user