using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Remotely.Shared.Models; using Remotely.Server.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace Remotely.Server.API { [Authorize] [ApiController] [Route("api/[controller]")] public class DevicesController : Controller { public DevicesController(DataService dataService, UserManager userManager) { this.DataService = dataService; this.UserManager = userManager; } private DataService DataService { get; set; } private UserManager UserManager { get; set; } // GET: api/ [HttpGet] public async Task> Get() { var user = await UserManager.GetUserAsync(User); var devices = DataService.GetAllDevicesForUser(user.Id); return devices; } // GET api//5 [HttpGet("{id}")] public async Task Get(string id) { var user = await UserManager.GetUserAsync(User); return DataService.GetDeviceForUser(user.Id, id); } } }