Esempio n. 1
0
        public HttpResponseMessage Post([FromBody] SingleSpeakerRequest request)
        {
            HttpResponseMessage response;

            try
            {
                SpeakerEventsResponse speakersResponse = new SpeakerEventsResponse();
                speakersResponse.SpeakerEvents = new ObservableCollection <TechReady.Common.Models.Event>();

                using (DbModel.TechReadyDbContext ctx = new DbModel.TechReadyDbContext())
                {
                    var speakers = (from c in ctx.Speakers
                                    where c.SpeakerID == request.SpeakerId
                                    select c).FirstOrDefault();

                    speakersResponse.SpeakerEvents =
                        CreateDxSpeaker(speakers);
                }

                response = this.Request.CreateResponse(HttpStatusCode.OK, speakersResponse);
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(300));
            }
            catch (Exception ex)
            {
                HttpError myCustomError = new HttpError(ex.Message)
                {
                    { "IsSuccess", false }
                };
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, myCustomError));
            }
            return(response);
        }
        public async void GetUpcommingSessions()
        {
            if (NetworkHelper.IsNetworkAvailable() == false)
            {
                return;
            }
            try
            {
                this.OperationInProgress = true;

                SingleSpeakerRequest request = new SingleSpeakerRequest()
                {
                    SpeakerId = this.Speaker.SpeakerId
                };

                var result = await ServiceProxy.CallService("api/SpeakerEvents", JsonConvert.SerializeObject(request));


                if (result.IsSuccess)
                {
                    var speakerEventsResponse = JsonConvert.DeserializeObject <SpeakerEventsResponse>(result.response);
                    if (speakerEventsResponse.SpeakerEvents != null)
                    {
                        Speaker.SpeakerEvents = this.FilterEvents(speakerEventsResponse.SpeakerEvents);
                        OnPropertyChanged("Speaker");
                        OnPropertyChanged("SpeakerEvents");
                        OnPropertyChanged("IsSessionsAvailable");
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(
                    "Exception on: SpeakerDetailsPageVM.GetSpeakerDetails(): ExceptionMessage: " + e.Message);
                OnPropertyChanged("");
            }
            finally
            {
                //if (Speaker.SpeakerEvents != null && Speaker.SpeakerEvents.Count > 0)
                //{
                //    IsSessionsAvailable = true;
                //}
                //else
                //{
                //    IsSessionsAvailable = false;
                //}
                this.OperationInProgress = false;
                OnPropertyChanged("");
            }
        }
        //public async void GetUpcomingSession()
        //{
        //    if(this.Speaker == null)
        //    {
        //        return;
        //    }
        //    if(NetworkHelper.IsNetworkAvailable() == false)
        //    {
        //        return;
        //    }
        //    this.OperationInProgress = true;
        //    this.Speaker.SpeakerEvents = await EventService.GetService(this.Speaker.SessionList);
        //    this.OperationInProgress = false;
        //}

        public async Task GetSpeakerDetails(TrackSpeaker args)
        {
            var trackSpeaker = args;

            if (NetworkHelper.IsNetworkAvailable() != false)
            {
                try
                {
                    this.OperationInProgress = true;

                    SingleSpeakerRequest request = new SingleSpeakerRequest()
                    {
                        SpeakerId = trackSpeaker.SpeakerId
                    };

                    var result = await ServiceProxy.CallService("api/SingleSpeaker", JsonConvert.SerializeObject(request));


                    if (result.IsSuccess)
                    {
                        var speakerDetails = JsonConvert.DeserializeObject <SingleSpeakerResponse>(result.response);
                        if (speakerDetails.TrackSpeaker != null)
                        {
                            trackSpeaker = speakerDetails.TrackSpeaker;
                        }
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Exception on: SpeakerDetailsPageVM.GetSpeakerDetails(): ExceptionMessage: " + e.Message);
                    OnPropertyChanged("");
                }
                finally
                {
                    this.OperationInProgress = false;
                    OnPropertyChanged("");
                }
            }

            this.Speaker = trackSpeaker;
            OnPropertyChanged("Speaker");
        }