Upload files to 'STORestApi/Controllers'
This commit is contained in:
parent
8c1d7c1ea3
commit
2d94d8e7b2
97
STORestApi/Controllers/CarController.cs
Normal file
97
STORestApi/Controllers/CarController.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using STOContracts.BindingModels;
|
||||
using STOContracts.BusinessLogicsContracts;
|
||||
using STOContracts.SearchModels;
|
||||
using STOContracts.ViewModels;
|
||||
using STODatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace STORestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CarController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _logic;
|
||||
|
||||
public CarController(ILogger<CarController> logger, ICarLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CarViewModel>? GetCarList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка машин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CarViewModel? GetCar(int CarId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new CarSearchModel
|
||||
{
|
||||
Id = CarId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения машины по Id={Id}", CarId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public void UpdateCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
STORestApi/Controllers/CarPartController.cs
Normal file
97
STORestApi/Controllers/CarPartController.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using STOContracts.BindingModels;
|
||||
using STOContracts.BusinessLogicsContracts;
|
||||
using STOContracts.SearchModels;
|
||||
using STOContracts.ViewModels;
|
||||
using STODatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace STORestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CarPartController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarPartLogic _logic;
|
||||
|
||||
public CarPartController(ILogger<CarPartController> logger, ICarPartLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CarPartViewModel>? GetCarPartList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка запчастей");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CarPartViewModel? GetCarPart(int CarPartId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new CarPartSearchModel
|
||||
{
|
||||
Id = CarPartId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения запчасти по Id={Id}", CarPartId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCarPart(CarPartBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания запчасти");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public void UpdateCarPart(CarPartBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления запчасти");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteCarPart(CarPartBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления запчасти");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
112
STORestApi/Controllers/ClientController.cs
Normal file
112
STORestApi/Controllers/ClientController.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using STOContracts.BindingModels;
|
||||
using STOContracts.BusinessLogicsContracts;
|
||||
using STOContracts.SearchModels;
|
||||
using STOContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace STORestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _logic;
|
||||
|
||||
public ClientController(ILogger<ClientController> logger, IClientLogic client)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = client;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ClientViewModel>? GetClientList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка клиентов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ClientViewModel? GetClient(int ClientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Id = ClientId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения клиетна по Id={Id}", ClientId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ClientViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания работника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public void UpdateClient(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления работника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteClient(ClientBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления работника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
STORestApi/Controllers/ServiceController.cs
Normal file
97
STORestApi/Controllers/ServiceController.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using STOContracts.BindingModels;
|
||||
using STOContracts.BusinessLogicsContracts;
|
||||
using STOContracts.SearchModels;
|
||||
using STOContracts.ViewModels;
|
||||
using STODatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace STORestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IServiceLogic _logic;
|
||||
|
||||
public ServiceController(ILogger<ServiceController> logger, IServiceLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetServiceList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка сервисов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ServiceViewModel? GetService(int ServiceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ServiceSearchModel
|
||||
{
|
||||
Id = ServiceId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения сервиса по Id={Id}", ServiceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания сервиса");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public void UpdateService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления сервиса");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления сервиса");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
STORestApi/Controllers/TechnicalWorkController.cs
Normal file
97
STORestApi/Controllers/TechnicalWorkController.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using STOContracts.BindingModels;
|
||||
using STOContracts.BusinessLogicsContracts;
|
||||
using STOContracts.SearchModels;
|
||||
using STOContracts.ViewModels;
|
||||
using STODatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace STORestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class TechnicalWorkController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITechnicalWorkLogic _logic;
|
||||
|
||||
public TechnicalWorkController(ILogger<TechnicalWorkController> logger, ITechnicalWorkLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<TechnicalWorkViewModel>? GetTechnicalWorkList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public TechnicalWorkViewModel? GetTechnicalWork(int TechnicalWorkId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new TechnicalWorkSearchModel
|
||||
{
|
||||
Id = TechnicalWorkId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения ТО по Id={Id}", TechnicalWorkId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public void UpdateTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user