1 |
|
using Core.Contexts;
|
2 |
|
using Microsoft.AspNetCore.Mvc;
|
3 |
|
using Core.Entities;
|
4 |
|
using Core.Enums;
|
5 |
|
using Core.Services;
|
6 |
|
|
7 |
|
namespace Backend.Controllers
|
8 |
|
{
|
9 |
|
|
10 |
|
[ApiController]
|
11 |
|
[Route("[controller]")]
|
12 |
|
public class WeatherForecastController : ControllerBase
|
13 |
|
{
|
14 |
|
private readonly IUserService _userService;
|
15 |
|
|
16 |
|
private static readonly string[] Summaries = new[]
|
17 |
|
{
|
18 |
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
19 |
|
};
|
20 |
|
|
21 |
|
private readonly ILogger<WeatherForecastController> _logger;
|
22 |
|
|
23 |
|
public WeatherForecastController(ILogger<WeatherForecastController> logger, IUserService userService)
|
24 |
|
{
|
25 |
|
_logger = logger;
|
26 |
|
_userService = userService;
|
27 |
|
}
|
28 |
|
|
29 |
|
[HttpGet(Name = "GetWeatherForecast")]
|
30 |
|
public IEnumerable<WeatherForecast> Get()
|
31 |
|
{
|
32 |
|
/*User? u = _userService.CreateUser("username2", "name", "surname", "password", ERole.ANNOTATOR);
|
33 |
|
u = _userService.UpdateUser(u, "username3");
|
34 |
|
u = _userService.ChangePassword(u, "password2");*/
|
35 |
|
User u = _userService.CheckUsernamePassword("asdfghjkl", "password2");
|
36 |
|
|
37 |
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
38 |
|
{
|
39 |
|
Date = DateTime.Now.AddDays(index),
|
40 |
|
TemperatureC = Random.Shared.Next(-20, 55),
|
41 |
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
42 |
|
})
|
43 |
|
.ToArray();
|
44 |
|
}
|
45 |
|
}
|
46 |
|
}
|
Removed weather controller