Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7bbb9c44

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Removed weather controller

Zobrazit rozdíly:

Backend/Backend/Controllers/WeatherForecastController.cs
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
}
Backend/Backend/WeatherForecast.cs
1
namespace Backend
2
{
3
    public class WeatherForecast
4
    {
5

  
6
        public DateTime Date { get; set; }
7

  
8
        public int TemperatureC { get; set; }
9

  
10
        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
11

  
12
        public string? Summary { get; set; }
13
    }
14
}

Také k dispozici: Unified diff