public async Task <IActionResult> GetAll() { var permList = await _penaltyRepository.GetAllPenaltyAsync(); var allPenalties = ( from perm in permList select perm into penalty where penalty != null && (!penalty.deprecationTime.HasValue || penalty.deprecationTime.Value > DateTime.UtcNow) select BsonSerializer.Deserialize <Penalty>(penalty.ToBsonDocument()) into pnlt select new Dictionary <string, string> { { "id", "\"" + pnlt.id + "\"" }, { "Penalty", pnlt.ToJson() } } ).ToList(); var permitJson = new JsonStringResult(allPenalties); return(permitJson); }