Ejemplo n.º 1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "recent/{userId}")] HttpRequest req,
            [Table(
                 TableConstants.UserTable,
                 Connection = Constants.StorageConnection
                 )] CloudTable userTable,
            string userId,
            ILogger log)
        {
            await userTable.CreateIfNotExistsAsync();

            var repo   = new UserRepository(userTable);
            var entity = await repo.GetUserAsync(userId);

            if (entity != null && entity.Active)
            {
                var playHistory = await SpotifyHelper.GetRecentlyPlayedTracksAsync(userId);

                return(new JsonResult(playHistory));
            }

            return(new NotFoundResult());
        }