public async void RemoveNotification_Click(Notification notification)
        {
            //notification.Removed = true;
            //OnPropertyChanged("Removed");

            //service call on removed item from item and savedd it locally
            try
            {
                //if (this.AllNotifications != null && this.AllNotifications.Count > 0 && this.AllNotifications.Contains(notification))
                //{
                //    this.AllNotifications.Remove(notification);
                //    OnPropertyChanged("AllNotifications");
                //    OnPropertyChanged("AreNotificationsAvailable");
                //}

                notification.Removed = true;
                if ((this.AllNotifications.FirstOrDefault(x => x.NotificationID == notification.NotificationID) != null))
                {
                    (this.AllNotifications.FirstOrDefault(x => x.NotificationID == notification.NotificationID)).Removed = true;
                }
                OnPropertyChanged("Removed");
                OnPropertyChanged("AllNotifications");
                OnPropertyChanged("AllShownNotifications");
                OnPropertyChanged("AreNotificationsAvailable");

                if (NetworkHelper.IsNetworkAvailable() == false)
                {
                    await LocalStorage.SaveJsonToFile(this.AllNotifications, "allNotifications");

                    return;
                }

                var model = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                if (model != null)
                {
                    if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == true)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/RemoveNotification", JsonConvert.SerializeObject(new TechReady.Common.DTO.MarkNotificationRequest()
                        {
                            AppUserId      = model.UserId,
                            NotificationId = notification.NotificationID.ToString()
                        }));

                        if (result.IsSuccess)
                        {
                            //model.SaveUserRegitration();
                        }
                    }
                }

                await LocalStorage.SaveJsonToFile(this.AllNotifications, "allNotifications");
            }
            catch
            {
            }
        }
        public async Task Follow_Click(object sender)
        {
            try {
                var data = await LocalStorage.ReadJsonFromFile <List <Event> >("followedEvents");

                if (data == null)
                {
                    data = new List <Event>();
                }
                //var viewModel = this.DataContext as EventDetailsPageViewModel;
                //if (viewModel == null)
                //{
                //    return;
                //}

                if (data.FirstOrDefault(x => x.EventId == this.Event.EventId) == null)
                {
                    data.Add(this.Event);
                    this.Event.IsFollowed = true;
                }
                else
                {
                    data.Remove(this.Event);
                    this.Event.IsFollowed = false;
                }
                var model = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                if (model != null)
                {
                    if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == true)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/FollowEvent", JsonConvert.SerializeObject(new TechReady.Common.DTO.FollowEventRequest()
                        {
                            EventId   = Event.EventId.ToString(),
                            AppUserId = model.UserId,
                            Follow    = Event.IsFollowed
                        }));

                        if (result.IsSuccess)
                        {
                            model.SaveUserRegitration();
                        }
                    }
                }
                await LocalStorage.SaveJsonToFile(data, "followedEvents");

                if (FollowedChanged != null)
                {
                    this.FollowedChanged();
                }
            }catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception thrown at EventDetailsPage view model " + ex.Message);
            }
        }
        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 Task GetEvents()
        {
            try
            {
                this.OperationInProgress = true;

                ObservableCollection <Event> model = await LocalStorage.ReadJsonFromFile <ObservableCollection <Event> >("allevents");
                await SetEvents(model);

                if (NetworkHelper.IsNetworkAvailable() == false)
                {
                    if (model == null)
                    {
                        await MessageHelper.ShowMessage("Please connect to internet to download latest events");

                        return;
                    }
                }
                else
                {
                    HomeRequest request = new HomeRequest()
                    {
                    };

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

                    if (result.IsSuccess)
                    {
                        var homeResponse = JsonConvert.DeserializeObject <HomeResponse>(result.response);

                        model = homeResponse.AllEvents;
                        await LocalStorage.SaveJsonToFile(homeResponse.AllEvents, "allevents");
                    }
                    else
                    {
                        //await MessageHelper.ShowMessage(result.Error.Message);
                    }
                }

                await SetEvents(model);
            }
            catch
            {
            }
            finally
            {
                this.OperationInProgress = false;
            }
        }
        public async void Notification_Tapped(object sender)
        {
            try
            {
                var notification = sender as Notification;
                notification.Read = true;
                //this.AllNotifications.FirstOrDefault(n => n.NotificationID == notification.NotificationID).Read = true;
                OnPropertyChanged("Read");

                if (NetworkHelper.IsNetworkAvailable() == false)
                {
                    await LocalStorage.SaveJsonToFile(this.AllNotifications, "allNotifications");

                    return;
                }

                var model = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                if (model != null)
                {
                    if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == true)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/MarkNotification", JsonConvert.SerializeObject(new TechReady.Common.DTO.MarkNotificationRequest()
                        {
                            AppUserId      = model.UserId,
                            NotificationId = notification.NotificationID.ToString()
                        }));

                        if (result.IsSuccess)
                        {
                            //model.SaveUserRegitration();
                        }
                    }
                }

                await LocalStorage.SaveJsonToFile(this.AllNotifications, "allNotifications");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception thrown at HUB PAGE NOTIFICATION TAPPED " + ex.Message);
            }
            finally
            {
            }
        }
        //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");
        }
        public static async Task <ObservableCollection <LearningResource> > GetLearningResourcesFromServer(
            LearningResourcesRequest request)
        {
            try
            {
                var result =
                    await ServiceProxy.CallService("api/LearningResources", JsonConvert.SerializeObject(request));

                if (result.IsSuccess)
                {
                    var homeResponse = JsonConvert.DeserializeObject <LearningResourcesResponse>(result.response);
                    return(homeResponse.LearningResources);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #8
0
        public async Task GetSpeakers()
        {
            this.OperationInProgress = true;
            try
            {
                ObservableCollection <TrackSpeaker> model;
                model = await LocalStorage.ReadJsonFromFile <ObservableCollection <TrackSpeaker> >("allspeakers");

                if (NetworkHelper.IsNetworkAvailable())
                {
                    SpeakersRequest request = new SpeakersRequest()
                    {
                    };

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

                    if (result.IsSuccess)
                    {
                        var homeResponse = JsonConvert.DeserializeObject <SpeakersResponse>(result.response);
                        await LocalStorage.SaveJsonToFile(this.Speakers, "allspeakers");

                        model = homeResponse.AllSpeakers;
                    }
                }

                if (model != null)
                {
                    this.Speakers =
                        model;
                    _allSpeakers = model;
                }
            }
            finally
            {
                this.OperationInProgress = false;
            }
        }
 public void ArchiveDocument(string corpCode)
 {
     _proxy.CallService("ArchiveDocument", true, corpCode);
 }
Exemple #10
0
        public async Task <bool> SaveFeedback()
        {
            if (string.IsNullOrEmpty(this.UserName))
            {
                await MessageHelper.ShowMessage("Please provide your Name");

                return(false);
            }

            else if (string.IsNullOrEmpty(this.Email))
            {
                await MessageHelper.ShowMessage("Please provide your Email");

                return(false);
            }

            else if (this.SelectedFeedbackType == null)
            {
                await MessageHelper.ShowMessage("Please provide your FeedbackType");

                return(false);
            }


            else if (string.IsNullOrWhiteSpace(this.Feedback))
            {
                await MessageHelper.ShowMessage("Please provide your Feedback");

                return(false);
            }



            string email = this.Email;
            Regex  regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match  match = regex.Match(email);

            if (!match.Success)
            {
                await MessageHelper.ShowMessage("Please enter valid email address");

                return(false);
            }



            try
            {
                this.OperationInProgress = true;
                if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == false)
                {
                    await MessageHelper.ShowMessage("Please connect to internet to submit feedback");

                    return(false);
                }
                // Fetch data about the user
                //saves and updates data on server
                var model = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                if (model != null)
                {
                    if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == true)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/Feedback", JsonConvert.SerializeObject(
                                                                        new FeedbackRequest()
                        {
                            Name         = this.UserName,
                            Email        = this.Email,
                            FeedbackType = this.SelectedFeedbackType,
                            Feedback     = this.Feedback,
                            AppUserId    = model.UserId
                        }));

                        if (result.IsSuccess)
                        {
                            FeedbackResponse response = JsonConvert.DeserializeObject <FeedbackResponse>(result.response);
                            // await MessageHelper.ShowMessage(response.ResponseText);
                            this.ResponseMessage = response.ResponseText;
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                this.OperationInProgress = false;
            }
        }
        public async Task GetNotifications()
        {
            this.OperationInProgress = true;
            try
            {
                ObservableCollection <Notification> model = null;
                if (NetworkHelper.IsNetworkAvailable() == false)
                {
                    model = await LocalStorage.ReadJsonFromFile <ObservableCollection <Notification> >("allNotifications");

                    this.AllNotifications = model;
                    //await MessageHelper.ShowMessage("Please connect to internet to download latest events");
                    return;
                }
                else
                {
                    // Fetch data about the user
                    //saves and updates data on server
                    var userModel = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                    if (userModel != null)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/Notifications", JsonConvert.SerializeObject(
                                                                        new NotificationsRequest()
                        {
                            AppUserId = userModel.UserId
                        }));

                        if (result.IsSuccess)
                        {
                            NotificationsResponse response = JsonConvert.DeserializeObject <NotificationsResponse>(result.response);
                            model = await LocalStorage.ReadJsonFromFile <ObservableCollection <Notification> >("allNotifications");

                            if (model != null)
                            {
                                foreach (var notif in model)
                                {
                                    //response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID && notif.Read));
                                    if (notif.Read)
                                    {
                                        if (response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)) != null)
                                        {
                                            response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)).Read = true;
                                            this.Notification_Tapped(response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)));
                                        }
                                    }
                                    if (notif.Removed)
                                    {
                                        if (response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)) != null)
                                        {
                                            response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)).Removed = true;
                                            this.RemoveNotification_Click(response.UserNotifications.FirstOrDefault(n => (n.NotificationID == notif.NotificationID)));
                                        }
                                    }
                                }
                            }
                            this.AllNotifications = new ObservableCollection <Notification>(response.UserNotifications.Where(x => x.Removed == false).ToList().OrderByDescending(x => x.PushDateTime));
                            await LocalStorage.SaveJsonToFile(this.AllNotifications, "allNotifications");
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            finally
            {
                this.OperationInProgress = false;
            }
        }
Exemple #12
0
        public async static void MarkVideos(object sender)
        {
            try
            {
                var data = await LocalStorage.ReadJsonFromFile <List <LearningResource> >("watchedVideos");

                if (data == null)
                {
                    data = new List <LearningResource>();
                }

                var resource = sender as LearningResource;
                if (resource == null)
                {
                    return;
                }

                if (data.FirstOrDefault(x => x.LearningResourceID == resource.LearningResourceID) == null)
                {
                    resource.LastWatchedTime = DateTime.Now;
                    data.Add(resource);
                }
                else
                {
                    data.Remove(resource);
                    resource.LastWatchedTime = DateTime.Now;
                    //data.Add(resource);
                }

                var model = await LocalStorage.ReadJsonFromFile <UserRegistrationPageViewModel>("registration");

                if (model != null)
                {
                    if (Helpers.NetworkHelper.NetworkHelper.IsNetworkAvailable() == true)
                    {
                        //TODO SHIV: API Check
                        var result = await ServiceProxy.CallService("api/WatchedLearningResource", JsonConvert.SerializeObject(new TechReady.Common.DTO.WatchedLearningResourceRequest()
                        {
                            AppUserId = model.UserId,
                            WatchedLearningResourceId = resource.LearningResourceID.ToString()
                        }));

                        if (result.IsSuccess)
                        {
                            model.SaveUserRegitration();
                        }
                        //if (result.IsSuccess)
                        //{
                        //    //var homeResponse = JsonConvert.DeserializeObject<SpeakersResponse>(result.response);
                        //    //this.Speakers = homeResponse.AllSpeakers;
                        //    //this._allSpeakers = new ObservableCollection<TrackSpeaker>();
                        //    //foreach (var speaker in this.Speakers)
                        //    //{
                        //    //    _allSpeakers.Add(speaker);
                        //    //}
                        //    //await LocalStorage.SaveJsonToFile(this.Speakers, "allspeakers");
                        //}
                    }
                }

                await LocalStorage.SaveJsonToFile(data, "watchedVideos");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception thrown at LearnPage view Model " + ex.Message);
            }
        }
        public async Task <bool> SaveUserRegitration()
        {
            this.IsValid = true;

            if (string.IsNullOrEmpty(this.FullName))
            {
                await MessageHelper.ShowMessage("Please provide your Name");

                IsValid = false;
                return(false);
            }

            else if (this.City == null)
            {
                await MessageHelper.ShowMessage("Please choose your City");

                IsValid = false;
                return(false);
            }

            else if (string.IsNullOrEmpty(this.Email))
            {
                await MessageHelper.ShowMessage("Please provide your Email");

                IsValid = false;
                return(false);
            }

            else if (this.SelectedAudienceType == null)
            {
                await MessageHelper.ShowMessage("What describes you best?");

                IsValid = false;
                return(false);
            }

            else if (this.SelectedAudienceOrgType == null)
            {
                await MessageHelper.ShowMessage("Please select your Organization");

                IsValid = false;
                return(false);
            }

            else if (this.SecondaryTechnologies.FirstOrDefault(x => x.IsSelected) == null)
            {
                await MessageHelper.ShowMessage("Please select your Technologies you are interested in");

                IsValid = false;
                return(false);
            }



            string email = this.Email;
            Regex  regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match  match = regex.Match(email);

            if (!match.Success)
            {
                await MessageHelper.ShowMessage("Please enter valid email address");

                IsValid = false;
                return(false);
            }


            try
            {
                this.OperationInProgress = true;

                var pf = new ProfileRequest()
                {
                    FullName           = this.FullName,
                    Email              = this.Email,
                    AuthProvider       = this.AuthProvider,
                    AuthProviderUserId = this.AuthProviderUserId,
                    City = this.City,
                    SelectedAudienceType    = this.SelectedAudienceType,
                    SelectedAudienceOrgType = this.SelectedAudienceOrgType,
                    SecondaryTechnologies   = this.SecondaryTechnologies,
                    DeviceId       = this.DeviceId,
                    DevicePlatform = NotificationsHelper.Platform,
                    PushEnabled    = this.PushEnabled,
                    PushId         = await NotificationsHelper.GetPushId(),
                    Town           = this.Town,
                    Location       = this.Location
                }
                ;

                // Fetch data about the user
                //saves and updates data on server
                var result =
                    await ServiceProxy.CallService("api/Profile", JsonConvert.SerializeObject(pf));

                if (result.IsSuccess)
                {
                    ProfileResponse response = JsonConvert.DeserializeObject <ProfileResponse>(result.response);

                    if (response.UserId != 0) // check if user is exsting or not ,,, if 0 means update failed.
                    {
                        this.DeviceId = response.DeviceId;
                        this.UserId   = response.UserId.ToString();
                        await LocalStorage.SaveJsonToFile(this, "registration");

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                this.OperationInProgress = false;
            }

            return(false);
        }
        public async Task <bool> GetTechnologes()
        {
            if (NetworkHelper.IsNetworkAvailable() == false)
            {
                await MessageHelper.ShowMessage("You require an active network connection to internet for registration");

                this.ShowError = true;
                return(false);
            }

            try
            {
                this.OperationInProgress = true;

                // Fetch data about the existing user and assign it to view model.
                var checkProfileResponse = await ServiceProxy.CallService("api/CheckProfile", JsonConvert.SerializeObject(new CheckProfileRequest()
                {
                    AuthProvider       = this.AuthProvider,
                    AuthProviderUserId = this.AuthProviderUserId
                }));

                if (checkProfileResponse.IsSuccess)
                {
                    CheckProfileResponse authUserInfoResponse = JsonConvert.DeserializeObject <CheckProfileResponse>(checkProfileResponse.response);

                    this.AudienceTypes         = authUserInfoResponse.AudienceTypes;
                    this.AllAudienceOrgTypes   = authUserInfoResponse.AudienceOrgTypes;
                    this.SecondaryTechnologies = authUserInfoResponse.SecondaryTechnologies;
                    this.Cities = new ObservableCollection <City>(authUserInfoResponse.Cities);
                    if (this.Cities == null)
                    {
                        this.Cities = new ObservableCollection <City>();
                    }
                    else if (this.Cities.Count > 0)
                    {
                        this.City = this.Cities[0];
                    }

                    if (this.AudienceTypes == null)
                    {
                        this.AudienceTypes = new List <AudienceType>();
                    }
                    else if (this.AudienceTypes.Count > 0)
                    {
                        this.SelectedAudienceType = this.AudienceTypes[0];
                    }


                    if (this.AudienceOrgTypes == null)
                    {
                        this.AudienceTypes = new List <AudienceType>();
                    }
                    else if (this.AudienceOrgTypes.Count > 0)
                    {
                        this.SelectedAudienceOrgType = this.AudienceOrgTypes[0];
                    }



                    this.OnPropertyChanged("AudienceTypes");
                    this.OnPropertyChanged("SecondaryTechnologies");
                    this.OnPropertyChanged("Cities");

                    if (authUserInfoResponse.IsRegistered)  // check if user is exsting or not
                    {
                        this.FullName           = authUserInfoResponse.FullName;
                        this.Email              = authUserInfoResponse.Email;
                        this.AuthProvider       = authUserInfoResponse.AuthProvider;
                        this.AuthProviderUserId = authUserInfoResponse.AuthProviderUserId;
                        this.City                    = authUserInfoResponse.City;
                        this.Town                    = authUserInfoResponse.Town;
                        this.Location                = authUserInfoResponse.Location;
                        this.SelectedAudienceType    = authUserInfoResponse.SelectedAudienceType;
                        this.SelectedAudienceOrgType = authUserInfoResponse.SelectedAudienceOrgType;
                        this.DeviceId                = authUserInfoResponse.DeviceId;
                        this.UserId                  = authUserInfoResponse.UserId;

                        if (!string.IsNullOrEmpty(this.DeviceId))
                        {
                            this.PushEnabled = true;
                        }

                        await LocalStorage.SaveJsonToFile(this, "registration");

                        return(true);
                    }
                    else
                    {
                        await this.SetCity(await GeoLocationHelper.GetCity(this.Cities.ToList()));
                    }
                }
                //else
                //{
                //    // if fetch data : FAILED.
                //    //unable to register you... unable to save your profile...
                //}
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                this.OperationInProgress = false;
            }
            return(false);
        }