using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using RdtClient.Data.Models.Data; using RdtClient.Service.Models; using RdtClient.Service.Services; namespace RdtClient.Web.Controllers { [Authorize] [Route("Api/Settings")] public class SettingsController : Controller { private readonly ISettings _settings; private readonly ITorrents _torrents; public SettingsController(ISettings settings, ITorrents torrents) { _settings = settings; _torrents = torrents; } [HttpGet] [Route("")] public async Task>> Get() { var result = await _settings.GetAll(); return Ok(result); } [HttpPut] [Route("")] public async Task Update([FromBody] SettingsControllerUpdateRequest request) { await _settings.Update(request.Settings); _torrents.Reset(); return Ok(); } [HttpGet] [Route("Profile")] public async Task> Profile() { var profile = await _torrents.GetProfile(); return Ok(profile); } [HttpPost] [Route("TestPath")] public async Task> TestPath([FromBody] SettingsControllerTestPathRequest request) { await _settings.TestPath(request.Path); return Ok(); } } public class SettingsControllerUpdateRequest { public IList Settings { get; set; } } public class SettingsControllerTestPathRequest { public String Path { get; set; } } }