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