public async Task<IEnumerable<FootballPlayer>> GetAsync()
    {
      try
      {
        var dbContext = new DbContext();
        var playersRepository = new FootballPlayersRepository();

        return await playersRepository.GetAsync(dbContext);
      }
      catch (Exception ex)
      {
        _logger.LogError("Error occured: {0}", ex);
        return null;
      }
    }
    public async Task<int> GetCountPlayersAsync([FromQuery] bool active)
    {
      try
      {
        var dbContext = new DbContext();
        var playersRepository = new FootballPlayersRepository();

        if (active)
        {
          return await playersRepository.GetCountActiveAsync(dbContext);
        }
        else
        {
          return await playersRepository.GetCountAsync(dbContext);
        }

      }
      catch (Exception ex)
      {
        _logger.LogError("Error occured: {0}", ex);
        return 0;
      }

    }
    public async Task<IActionResult> UpdatePeriodsAsync(string id, [FromBody]dynamic data)
    {
      try
      {
        var dbContext = new DbContext();
        var playersRepository = new FootballPlayersRepository();

        var player = await playersRepository.GetAsync(dbContext, id);

        if (player == null)
        {
          return HttpNotFound();
        }
        else
        {
          var array = ((JObject)data)["periods"];

          List<PositionTimeperiod> list = new List<PositionTimeperiod>();

          foreach (var item in array)
          {
            var positionPeriod = item.ToObject<PositionTimeperiod>();
            list.Add(positionPeriod);
          }

          var updateResult = await playersRepository.Update(dbContext, id, list);

          if (updateResult.IsModifiedCountAvailable && updateResult.ModifiedCount == 1)
          {
            return Ok();
          }

          return HttpBadRequest();
        }
      }
      catch (Exception ex)
      {
        _logger.LogError("Error occured: {0}", ex);
        return HttpBadRequest();
      }

    }
    public async Task<IActionResult> UpdateAsync(string id)
    {
      try
      {
        string Column = Request.Headers["Column"];
        string NewValue = Request.Headers["NewValue"];

        if (Column == string.Empty || NewValue == string.Empty)
        {
          return HttpBadRequest();
        }

        var dbContext = new DbContext();
        var playersRepository = new FootballPlayersRepository();

        var updateResult = await playersRepository.Update(dbContext, id, Column, NewValue);

        if (updateResult.IsModifiedCountAvailable && updateResult.ModifiedCount == 1)
        {
          return Ok();
        }
        else
        {
          return HttpNotFound();
        }

      }
      catch (Exception ex)
      {
        _logger.LogError("Error occured: {0}", ex);
        return HttpBadRequest();
      }

    }