Добавил контроллеры

parent ea760aa5
using Microsoft.AspNetCore.Mvc;
using Payment.WebApi.Models.DbModels;
using Payment.WebApi.Repositories.Interfaces;
namespace Payment.WebApi.Controllers;
[ApiController]
public class SupplierController : Controller
{
private readonly ISupplierRepository _supplierRepository;
public SupplierController(ISupplierRepository supplierRepository)
{
_supplierRepository = supplierRepository;
}
public ActionResult<List<Supplier>> GetAll()
{
try
{
return Ok(_supplierRepository.GetAll());
}
catch (Exception e)
{
return StatusCode(500, new { errorMessage = e.Message });
}
}
}
\ No newline at end of file
using Microsoft.AspNetCore.Mvc;
using Payment.WebApi.Models.DbModels;
using Payment.WebApi.Repositories.Interfaces;
namespace Payment.WebApi.Controllers;
[ApiController]
public class UserController : Controller
{
private readonly IUserRepository _userRepository;
public UserController(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public ActionResult<User> GetUser(int id)
{
try
{
var user = _userRepository.GetFirstOrDefaultById(id);
if (user is null)
return NotFound();
return Ok(user);
}
catch (Exception e)
{
return StatusCode(500, new { errorMessage = e.Message });
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment