Beispiel #1
0
        public PubsPageViewModel(INavigationService navigationService,
                                 IApiService apiService) : base(navigationService)
        {
            Title = "Publicaciones";
            _navigationService = navigationService;
            _apiService        = apiService;
            _instance          = this;

            _user = JsonConvert.DeserializeObject <UserResponse>(Settings.User);

            //Encuesta();

            LoadPubs();
        }
Beispiel #2
0
        private async void LikeZone()
        {
            var rcts = JsonConvert.DeserializeObject <List <Reactions> >(Settings.Reactions);
            var user = JsonConvert.DeserializeObject <UserResponse>(Settings.User);

            var zoneid = JsonConvert.DeserializeObject <int>(Settings.ZoneId);


            var comment = this;



            var rct = rcts == null ? null : rcts.FirstOrDefault(r => r.CommentId == comment.Id &&
                                                                r.ZoneId == zoneid &&
                                                                r.UserId == user.Id);

            if (rct != null)
            {
                rcts.Remove(rct);

                if (comment.Like > 0)
                {
                    comment.Like--;
                    await ActCmm(zoneid, 0, comment.Id, -1);
                }
            }
            else
            {
                rct = new Reactions
                {
                    Id        = (rcts == null || rcts.Count == 0) ? 1 : rcts.Last().Id + 1,
                    CommentId = comment.Id,
                    ZoneId    = zoneid,
                    Tipo      = 2,
                    UserId    = user.Id
                };
                comment.Like++;
                await ActCmm(zoneid, 0, comment.Id, 1);

                if (rcts == null)
                {
                    rcts = new List <Reactions>();
                }

                rcts.Add(rct);
            }


            Settings.Reactions = JsonConvert.SerializeObject(rcts);



            await PubsPageViewModel.GetInstance().UpdateContentAsync();

            var Ps     = JsonConvert.DeserializeObject <PublicationsResponse>(Settings.Pubs);
            var parkId = JsonConvert.DeserializeObject <int>(Settings.ParkId);
            var zoneId = JsonConvert.DeserializeObject <int>(Settings.ZoneId);

            var park = Ps.Parks.ToList().Find(p => p.Id == parkId);
            var zone = park.Zones.ToList().Find(z => z.Id == zoneId);

            ZonePageViewModel.GetInstance().Zone = zone;

            ZonePageViewModel.GetInstance().LoadComments();
        }
Beispiel #3
0
        private async void LikePub()
        {
            var rcts = JsonConvert.DeserializeObject <List <Reactions> >(Settings.Reactions);
            var user = JsonConvert.DeserializeObject <UserResponse>(Settings.User);

            var pubid = JsonConvert.DeserializeObject <int>(Settings.PubId);

            var comment = this;



            var rct = rcts == null ? null : rcts.FirstOrDefault(r => r.CommentId == comment.Id &&
                                                                r.ContentId == pubid &&
                                                                r.UserId == user.Id);

            if (rct != null)
            {
                rcts.Remove(rct);

                if (comment.Like > 0)
                {
                    comment.Like--;
                    await ActCmm(0, pubid, comment.Id, -1);
                }
            }
            else
            {
                rct = new Reactions
                {
                    Id        = (rcts == null || rcts.Count == 0) ? 1 : rcts.Last().Id + 1,
                    CommentId = comment.Id,
                    ContentId = pubid,
                    Tipo      = 2,
                    UserId    = user.Id
                };
                comment.Like++;
                await ActCmm(0, pubid, comment.Id, 1);

                if (rcts == null)
                {
                    rcts = new List <Reactions>();
                }

                rcts.Add(rct);
            }


            Settings.Reactions = JsonConvert.SerializeObject(rcts);



            await PubsPageViewModel.GetInstance().UpdateContentAsync();

            var Ps        = JsonConvert.DeserializeObject <PublicationsResponse>(Settings.Pubs);
            var contentId = JsonConvert.DeserializeObject <int>(Settings.PubId);

            var content = Ps.Contents.ToList().Find(c => c.Id == contentId);

            PubPageViewModel.GetInstance().Content = content;

            PubPageViewModel.GetInstance().LoadComments();

            /* PubPageViewModel.GetInstance().Content = content;
             * PubPageViewModel.GetInstance().LoadComments();*/
        }