commit
d6c7dfeb3e
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
{
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
],
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
Binary file not shown.
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Dtos;
|
||||
using api.Models;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
|
||||
public class TeamsController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ITeamsRepository _repo;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly DataContext _context;
|
||||
|
||||
public TeamsController(DataContext context, ITeamsRepository repo, IMapper mapper,UserManager<User> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_repo = repo;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetTeams()
|
||||
{
|
||||
var result = await _repo.GetTeams();
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
|
||||
public interface ITeamsRepository
|
||||
{
|
||||
Task<IEnumerable<Team>> GetTeams();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public class TeamsRepository : ITeamsRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public TeamsRepository(DataContext context)
|
||||
{
|
||||
this._context = context;
|
||||
}
|
||||
public async Task<IEnumerable<Team>> GetTeams()
|
||||
{
|
||||
var teams = await _context.Teams.ToListAsync();
|
||||
|
||||
return teams;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
{
|
||||
"ProjectFilePath": "c:\\Users\\ZMiguel\\Desktop\\ENEI2019\\api\\api.csproj",
|
||||
"TargetFramework": "netcoreapp2.1",
|
||||
"TagHelpers": [],
|
||||
"Configuration": {
|
||||
"ConfigurationName": "MVC-2.1",
|
||||
"LanguageVersion": "2.1",
|
||||
"Extensions": [
|
||||
{
|
||||
"ExtensionName": "MVC-2.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue