upd
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s

This commit is contained in:
2026-06-01 22:47:06 +03:00
parent eb6235bd3e
commit 4f4e517f9f
51 changed files with 277 additions and 830 deletions
+59
View File
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Mvc;
using Strela.Models;
using Strela.Services;
namespace Strela.Controllers;
[ApiController]
[Route("api/[controller]")]
public class UserController : ControllerBase
{
private readonly ILogger<UserController> _logger;
public UserController(ILogger<UserController> logger)
{
_logger = logger;
}
//=========================== GET =================================//
[HttpGet("GetUsers")]
public List<User> GetList()
{
using (var db = new SQLiteService())
{
var usrs = db.Users.ToList();
return usrs;
}
}
[HttpGet("GetById")]
public User GetById(int id)
{
using (var db = new SQLiteService())
{
var usr = db.Users.Where(u => u.Id == id).FirstOrDefault();
return usr;
}
}
[HttpGet("GetByName")]
public User GetByName(string name)
{
using (var db = new SQLiteService())
{
var usr = db.Users.Where(u => u.Name == name).FirstOrDefault();
return usr;
}
}
//========================= POST ====================================//
[HttpPost("PostUser")]
public IActionResult PostUser(User usr)
{
using (var db = new SQLiteService())
{
db.Users.Add(usr);//.Where(u => u.Name == name).FirstOrDefault();
db.SaveChanges();
return Created();
}
}
}
@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace Strela.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}