Exemplo n.º 1
0
            public static async Task <ConfessSender> Post(string guid, bool isComment, string confessguid)
            {
                try
                {
                    string url     = $"like/add?guid={guid}&isComment={isComment}&key={Logic.GetKey()}&confess={confessguid}";
                    string content = await BaseClient.GetEntities(url);

                    ConfessSender data = JsonConvert.DeserializeObject <ConfessSender>(content);
                    return(data);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
Exemplo n.º 2
0
            public static async Task <ConfessSender> Post(string guid, bool isComment, string confessguid, string token, string key)
            {
                try
                {
                    string url     = $"dislike/add?key={key}&guid={guid}&isComment={isComment}&confess={confessguid}";
                    string content = await BaseClient.GetEntities(url, token);

                    ConfessSender data = JsonConvert.DeserializeObject <ConfessSender>(content);
                    return(data);
                }
                catch (Exception ex)
                {
                    return(null);
                }
            }
Exemplo n.º 3
0
            public static async Task <ConfessSender> Post(string guid, bool isComment, string confessguid)
            {
                try
                {
                    string url     = $"dislike/add?key={await Logic.GetKey()}&guid={guid}&isComment={isComment}&confess={confessguid}";
                    string content = await BaseClient.GetEntities(url);

                    ConfessSender data = JsonConvert.DeserializeObject <ConfessSender>(content);
                    return(data);
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                    return(null);
                }
            }
Exemplo n.º 4
0
        public ActionResult <ConfessSender> Post(string guid, bool isComment, string key, string confess)
        {
            try
            {
                bool          exist  = Store.LikeClass.Post(guid, isComment, key);
                ConfessSender sender = new ConfessSender()
                {
                    Loader = Store.ConfessClass.FetchOneConfessLoader(confess, key), IsSuccessful = exist
                };

                //return data
                return(Ok(sender));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.ToString()));
            }
        }
Exemplo n.º 5
0
        private async void Dislike_Tapped(object sender, EventArgs e)
        {
            if (!Logic.IsInternet())
            {
                DependencyService.Get <IMessage>().ShortAlert(Constants.No_Internet);
                return;
            }
            StackLayout label = (StackLayout)sender;
            string      guid  = label.ClassId;

            if (confess.Owner_Guid == await Logic.GetKey())
            {
                DependencyService.Get <IMessage>().ShortAlert("You can't dislike your Confession.");
            }
            else
            {
                //post a new dislike
                try
                {
                    ConfessSender result = await Store.DislikeClass.Post(guid, false, confess.Guid);

                    //update the model
                    //update the model
                    if (result != null & result.IsSuccessful & result.Loader != null)
                    {
                        this.BindingContext = Logic.ProcessConfessLoader(result.Loader);
                    }
                    else
                    {
                        if (result.Loader != null)
                        {
                            this.BindingContext = Logic.ProcessConfessLoader(result.Loader);
                        }

                        // label.ch.TextColor = Color.Gray;
                        Logic.VibrateNow();
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                }
            }
        }
Exemplo n.º 6
0
        private async void Dislike_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (!Logic.IsInternet())
            {
                await new MessageDialog("No INTERNET connection has been found.").ShowAsync();
                return;
            }
            SymbolIcon label = (SymbolIcon)sender;;
            string     guid  = label.Tag.ToString();

            if (confess.Owner_Guid == Logic.GetKey())
            {
                await new MessageDialog("You can't dislike your Confession.").ShowAsync();
            }
            else
            {
                //post a new dislike
                try
                {
                    ConfessSender result = await Online.DislikeClass.Post(guid, false, confess.Guid);

                    //update the model
                    //update the model
                    if (result != null & result.IsSuccessful & result.Loader != null)
                    {
                        this.DataContext = result.Loader;
                    }
                    else
                    {
                        if (result.Loader != null)
                        {
                            this.DataContext = result.Loader;
                        }

                        label.Foreground = new SolidColorBrush(Colors.Gray);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 7
0
        private async void Like_Tapped_Comment(object sender, TappedRoutedEventArgs e)
        {
            if (!Logic.IsInternet())
            {
                await new MessageDialog("No INTERNET connection has been found.").ShowAsync();
                return;
            }
            SymbolIcon    label = (SymbolIcon)sender;;
            string        guid  = label.Tag.ToString();
            CommentLoader load  = new CommentLoader();

            if (loaders.Any(d => d.Guid.Equals(guid)))
            {
                load = loaders.FirstOrDefault(d => d.Guid.Equals(guid));
            }
            //check if this user owns this confession


            if (load.Owner_Guid == Logic.GetKey())
            {
                await new MessageDialog("You can't like your Comment.").ShowAsync();
            }
            else
            {
                //post a new like
                try
                {
                    ConfessSender result = await Online.LikeClass.Post(guid, true, guid);

                    ConfessLoader data = result.Loader;
                    this.DataContext = data;

                    label.Foreground = Logic.GetColorFromHex("#1976D2");
                    LoadData();
                }
                catch (Exception)
                {
                }
            }
        }