2019-02-26 00:41:17 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
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;
|
|
|
|
|
|
|
|
namespace api.Controllers
|
|
|
|
{
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
[ApiController]
|
|
|
|
public class TeamsController : ControllerBase
|
|
|
|
{
|
|
|
|
private readonly DataContext context;
|
|
|
|
private readonly IUsersRepository _repo;
|
|
|
|
private readonly IMapper _mapper;
|
|
|
|
private readonly RoleManager<Role> _roleManager;
|
|
|
|
private readonly UserManager<User> _userManager;
|
|
|
|
public TeamsController(DataContext context,IUsersRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
|
|
|
|
{
|
|
|
|
this.context = context;
|
|
|
|
_mapper = mapper;
|
|
|
|
_roleManager = roleManager;
|
|
|
|
_userManager = UserManager;
|
|
|
|
_repo = repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GET api/teams
|
2019-02-26 01:52:05 +00:00
|
|
|
// GET all teams
|
2019-02-26 00:41:17 +00:00
|
|
|
[HttpGet]
|
|
|
|
public async Task<IActionResult> GetTeams()
|
|
|
|
{
|
2019-02-26 01:52:05 +00:00
|
|
|
var Teams = await context.Teams.ToArrayAsync();
|
|
|
|
return Ok(Teams);
|
2019-02-26 00:41:17 +00:00
|
|
|
}
|
2019-03-02 03:57:16 +00:00
|
|
|
|
|
|
|
// GET api/teams/e/[id]
|
|
|
|
// GET all teams for event id
|
|
|
|
[HttpGet("e/{id}")]
|
|
|
|
public async Task<IActionResult> GetTeamsEvent(int id)
|
|
|
|
{
|
|
|
|
var Teams = await context.Teams.FirstOrDefaultAsync(e=>e.EventId == id);
|
|
|
|
return Ok(Teams);
|
|
|
|
}
|
2019-02-26 00:41:17 +00:00
|
|
|
}
|
|
|
|
}
|