コード例 #1
0
        /// <summary>
        /// Attach Get Show Commands
        /// </summary>
        /// <param name="client">Spotify SDK Client</param>
        /// <param name="response">Show Response</param>
        /// <param name="overrideIsAttach">Override Is Attach?</param>
        public static void AttachGetShowCommands(
            this ISpotifySdkClient client,
            ShowResponse response,
            bool?overrideIsAttach = null)
        {
            var isAttach = GetConfig(client.Config.IsAttachGetShowCommands, overrideIsAttach);

            if (response != null)
            {
                // Show Command
                if (client.CommandActions.Show != null)
                {
                    response.Command = new GenericCommand <ShowResponse>(
                        client.CommandActions.Show);
                }
                // Episode Commands
                if (response?.Episodes?.Items != null)
                {
                    response.Episodes.Items.ForEach(item => client.AttachGetEpisodeCommands(item));
                }
                // Add User Playback Command
                response.AddUserPlaybackCommand = new GenericCommand <IPlaybackResponse>(
                    client.AddUserPlaybackHandler);
            }
        }
コード例 #2
0
        //显示地址信息
        public ShowResponse ShowressInfo(ShowRequest request)
        {
            ShowResponse response = new ShowResponse();

            response.User = Convert.ToInt32(BaseBLL <UserInfobll> .Instance.ShowressInfo());
            return(response);
        }
        public async Task <ShowResponse> UpdateAsync(FormAnnouncement announcement)
        {
            string path = $"/announcement/{announcement.Id.Value}";

            var response = await RequestService.PutAsync(path, announcement);

            var result = new ShowResponse(response);

            string message;

            if (result.StatusCode.Equals(HttpStatusCode.OK))
            {
                message = "Duyurunuz güncellendi.";
            }
            else
            if (result.StatusCode.Equals(HttpStatusCode.Unauthorized))
            {
                message = "Tekrar giriş yapmanız gerekmektedir.";
            }
            else
            {
                message = "Duyurunuz oluşturulamadı.";
            }

            DependencyService.Get <IMessage>().ShowShortTime(message);

            return(result);
        }
コード例 #4
0
ファイル: Show.cs プロジェクト: paulcallen/mystikos
 public Show(ShowResponse response)
 {
     Id          = response.Id;
     Title       = response.Title;
     Author      = response.Author;
     Description = response.Description;
     Image       = response.Image;
     Updated     = response.Updated;
     Episodes    = response.Episodes?.Select(resp => new Episode(resp));
     Categories  = response.Categories?.Select(resp => new Category(resp));
 }
コード例 #5
0
 public static ShowView ToShowView(this ShowResponse response)
 {
     return(new ShowView
     {
         Id = response.Id,
         Name = response.Name,
         Cast = response.Cast.Select(c => new PersonView
         {
             Id = c.Id,
             Name = c.Name,
             Birthday = c.Birthday
         }).OrderByDescending(o => o.Birthday).ToList()
     });
 }
コード例 #6
0
ファイル: Config.cs プロジェクト: scratchpadRepos/Playground
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteStartElement("RequestTemplates");
     foreach (string request in request_templates)
     {
         writer.WriteStartElement("Request");
         writer.WriteCData(request);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     writer.WriteElementString("URL", URL);
     writer.WriteElementString("SearchDateBeginInterval", SearchDateBeginInterval.ToString());
     writer.WriteElementString("SearchDateEndInterval", SearchDateEndInterval.ToString());
     writer.WriteElementString("ShowResponse", ShowResponse.ToString());
 }
コード例 #7
0
        /// <summary>
        /// Attach Get Show Toggles
        /// </summary>
        /// <param name="client">Spotify Sdk Client</param>
        /// <param name="response">Show Response</param>
        public static async Task AttachGetShowToggles(
            this ISpotifySdkClient client,
            ShowResponse response)
        {
            if (client.Config.IsAttachGetShowToggles && response != null)
            {
                // Toggle Favourites
                response.ToggleFavourite = await client.GetToggleAsync(
                    ToggleType.Favourites, response.Id, (byte)FavouriteType.Show);

                // Toggle Saved
                response.ToggleSaved = await client.GetToggleAsync(
                    ToggleType.Saved, response.Id, (byte)SavedType.Show);
            }
        }
        public async Task <ShowResponse> FetchByIdAsync(int id)
        {
            string path = $"/announcement/{id}";

            var response = await RequestService.GetAsync(path, null);

            var result = new ShowResponse(response);

            if (!result.StatusCode.Equals(HttpStatusCode.OK))
            {
                string message = "Duyuru çekilemedi.";
                DependencyService.Get <IMessage>().ShowShortTime(message);
            }

            return(result);
        }
コード例 #9
0
ファイル: ShowsService.cs プロジェクト: paulcallen/mystikos
 private Show GetShow(ShowResponse response)
 {
     return(new Show(response));
 }
コード例 #10
0
        /// <summary>
        /// Get popular shows by page
        /// </summary>
        /// <param name="page">Page to return</param>
        /// <param name="limit">The maximum number of shows to return</param>
        /// <param name="ct">Cancellation token</param>
        /// <param name="genre">The genre to filter</param>
        /// <param name="sortBy">The sort</param>
        /// <param name="ratingFilter">Used to filter by rating</param>
        /// <returns>Popular shows and the number of shows found</returns>
        public async Task <(IEnumerable <ShowJson> shows, int nbShows)> GetShowsAsync(int page,
                                                                                      int limit,
                                                                                      double ratingFilter,
                                                                                      string sortBy,
                                                                                      CancellationToken ct,
                                                                                      GenreJson genre = null)
        {
            var watch   = Stopwatch.StartNew();
            var wrapper = new ShowResponse();

            if (limit < 1 || limit > 50)
            {
                limit = Utils.Constants.MaxShowsPerPage;
            }

            if (page < 1)
            {
                page = 1;
            }

            var restClient = new RestClient(Utils.Constants.PopcornApi);
            var request    = new RestRequest("/{segment}", Method.GET);

            request.AddUrlSegment("segment", "shows");
            request.AddParameter("limit", limit);
            request.AddParameter("page", page);
            if (genre != null)
            {
                request.AddParameter("genre", genre.EnglishName);
            }
            request.AddParameter("minimum_rating", ratingFilter);
            request.AddParameter("sort_by", sortBy);
            try
            {
                var response = await restClient.ExecuteTaskAsync <ShowResponse>(request, ct);

                if (response.ErrorException != null)
                {
                    throw response.ErrorException;
                }

                wrapper = response.Data;
            }
            catch (Exception exception) when(exception is TaskCanceledException)
            {
                Logger.Debug(
                    "GetShowsAsync cancelled.");
            }
            catch (Exception exception)
            {
                Logger.Error(
                    $"GetShowsAsync: {exception.Message}");
                throw;
            }
            finally
            {
                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;
                Logger.Debug(
                    $"GetShowsAsync ({page}, {limit}) in {elapsedMs} milliseconds.");
            }

            var shows   = wrapper?.Shows ?? new List <ShowJson>();
            var nbShows = wrapper?.TotalShows ?? 0;

            return(shows, nbShows);
        }