private async void Send_Tapped(object sender, TappedRoutedEventArgs e) { if (!Logic.IsInternet()) { await new MessageDialog("No INTERNET connection has been found.").ShowAsync(); return; } //comment_Input if (string.IsNullOrWhiteSpace(comment_Input.Text)) { await new MessageDialog("Enter some text").ShowAsync(); return; } try { Comment newComment = new Comment() { Body = comment_Input.Text, Confess_Guid = confess.Guid, Owner_Guid = Logic.GetKey() }; newloader = await Online.CommentClass.CreateComment(newComment, confess.Guid); this.DataContext = newloader; await new MessageDialog("Comment Posted.").ShowAsync(); comment_Input.Text = string.Empty; LoadData(); } catch (Exception) { } }
public ActionResult <ConfessLoader> Add([FromBody] CommentPoster data) { try { bool isSafe = Logic.CheckSpamFree(data.Comment.Body.ToLower()); if (isSafe) { Store.CommentClass.CreateComment(data); Push.SendCommentNotification(data.Comment); } else { Push.NotifyOwnerOFSpam(data.Comment.Owner_Guid); } //send back the confession ConfessLoader loader = Store.ConfessClass.FetchOneConfessLoader(data.Comment.Confess_Guid, data.Comment.Owner_Guid); return(Ok(loader)); } catch (Exception ex) { return(new ConfessLoader() { }); } }
private static ConfessLoader GetConfessLoader(Confess dt, string key) { ConfessLoader loader = new ConfessLoader { Body = dt.Body, Category = dt.Category, Date = Shared.TimeAgo.Ago(dt.Date),//$"{dt.Date.ToLongDateString()} {dt.Date.ToShortTimeString()}", DateReal = dt.Date, DisLikes = DislikeClass.GetCount(dt.Guid, false), Likes = LikeClass.GetCount(dt.Guid, false), Guid = dt.Guid, Owner_Guid = dt.Owner_Guid, Title = dt.Title, CommentCount = CommentClass.GetCommentCount(dt.Guid), Seen = SeenClass.GetCount(dt.Guid) }; //load colors if (LikeClass.CheckExistence(dt.Guid, false, key)) { loader.LikeColorString = "#1976D2"; } if (DislikeClass.CheckExistence(dt.Guid, false, key)) { loader.DislikeColorString = "#1976D2"; } return(loader); }
public async Task <IActionResult> Detail() { string id = Request.Path.Value.Split('/').LastOrDefault(); SetCurrent(id); try { //Confess confess = await Store.ConfessClass.FetchOneConfessByGuid(id, GetToken(GetKey())); ConfessLoader loader = await Store.ConfessClass.FetchOneConfessLoaderByGuid(id, GetToken(GetKey()), GetKey()); List <CommentLoader> loaders = await Store.CommentClass.FetchComment(loader.Guid, GetToken(GetKey()), GetKey()); loaders.Reverse(); ViewBag.key = GetKey(); Modeller modeller = new Modeller() { ConfessLoader = loader, Loaders = loaders }; return(View(modeller)); // return RedirectToAction("Detail", "Home", modeller); } catch (Exception) { return(RedirectToActionPermanent("Index", "Home")); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is ConfessLoader && (ConfessLoader)e.Parameter != null) { confess = (ConfessLoader)e.Parameter; titleText.Text = confess.Title; LoadData(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is ConfessLoader && (ConfessLoader)e.Parameter != null) { confess = (ConfessLoader)e.Parameter; this.DataContext = confess; LoadData(); LoadSettings(); } }
internal static void SaveLoader(ConfessLoader incomingConfession) { if (Local.ConfessLoader.Exists(d => d.Id == incomingConfession.Id)) { Local.ConfessLoader.Update(incomingConfession); } else { Local.ConfessLoader.Insert(incomingConfession); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is ConfessLoader && (ConfessLoader)e.Parameter != null) { confess = (ConfessLoader)e.Parameter; title_text.Text = confess.Title; body_text.Text = confess.Body; categories.ItemsSource = Uwp.Helpers.Logic.Categories.ToList(); categories.SelectedValue = confess.Category; } }
public static ConfessLoader ProcessConfessLoader(ConfessLoader loader) { if (!string.IsNullOrEmpty(loader.LikeColorString)) { loader.LikeColor = Color.FromHex(loader.LikeColorString); } if (!string.IsNullOrEmpty(loader.DislikeColorString)) { loader.DislikeColor = Color.FromHex(loader.DislikeColorString); } return(loader); }
public Edit(ConfessLoader _confess) { InitializeComponent(); AdmobControl admobControl = new AdmobControl() { AdUnitId = AppConstants.HomeBannerId, HorizontalOptions = LayoutOptions.CenterAndExpand }; Ads.Children.Add(admobControl); confess = _confess; cat.ItemsSource = Logic.Categories.ToList(); this.BindingContext = _confess; }
public static async Task <ConfessLoader> DeleteComment(string guid, string ConfessGuid, string token, string key) { try { string url = $"comment/delete?guid={guid}&confess={ConfessGuid}&key={key}"; string content = await BaseClient.DeleteEntities(url, token); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { return(null); } }
public ActionResult <ConfessLoader> Delete(string guid, string confess, string key) { try { Store.CommentClass.DeleteComment(guid); ConfessLoader loader = Store.ConfessClass.FetchOneConfessLoader(confess, key); return(Ok(loader)); } catch (Exception ex) { return(new ConfessLoader() { }); } }
public static async Task <ConfessLoader> DeleteComment(string guid, string ConfessGuid) { try { string url = $"comment/delete?guid={guid}&confess={ConfessGuid}&key={await Logic.GetKey()}"; string content = await BaseClient.DeleteEntities(url); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); return(null); } }
private void List_View_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { ListView view = sender as ListView; if (view.SelectedItem == null) { return; } ConfessLoader confessrr = view.SelectedItem as ConfessLoader; Frame.Navigate(typeof(ViewPage), view.SelectedItem as ConfessLoader); view.SelectedItem = null; } catch (Exception) { } }
public ActionResult <ConfessLoader> FetchLoaderByGuid(string guid, string key) { try { //prepare responses ConfessLoader response = Store.ConfessClass.FetchOneConfessLoader(guid, key); //return data return(Ok(response)); } catch (Exception ex) { return(new ConfessLoader() { }); } }
public static async Task <ConfessLoader> FetchOneConfessLoaderByGuid(string guid, string token, string key) { try { string url = $"confess/fetchloader/guid?guid={guid}&key={key}"; string content = await BaseClient.GetEntities(url, token); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { return(new ConfessLoader() { }); } }
public ViewPage(ConfessLoader _confess) { InitializeComponent(); AdmobControl admobControl = new AdmobControl() { AdUnitId = AppConstants.ViewPageBannerId, HorizontalOptions = LayoutOptions.CenterAndExpand }; Ads.Children.Add(admobControl); confess = _confess; this.BindingContext = confess; //commentButton.IsVisible = confess.CommentCount !="0"; LoadSettings(); LoadSubscription(); }
public async Task UpdateConfession(string message) { //check for emptiness if (!string.IsNullOrEmpty(message)) { Confess data = JsonConvert.DeserializeObject <Confess>(message); bool isSafe = Logic.CheckSpamFree(data.Body.ToLower()); if (isSafe) { Store.ConfessClass.UpdateConfess(data); ConfessLoader confess = Store.ConfessClass.FetchOneConfessLoader(data.Guid, data.Owner_Guid); await Clients.All.SendAsync("ReceiveUpdateConfession", JsonConvert.SerializeObject(confess)); } else { Push.NotifyOwnerOFSpam(data.Owner_Guid); } } }
public static async Task <ConfessLoader> CreateComment(Comment comment, string confessGuid, string token, string key) { try { string url = $"comment/add"; CommentPoster poster = new CommentPoster() { Comment = comment, ConfessGuid = confessGuid, Key = key }; string content = await BaseClient.PostEntities(url, JsonConvert.SerializeObject(poster), token); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { return(null); } }
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) { } } }
public static async Task <ConfessLoader> CreateComment(Comment comment, string confessGuid) { try { string url = $"comment/add"; CommentPoster poster = new CommentPoster() { Comment = comment, ConfessGuid = confessGuid, Key = await Logic.GetKey() }; string content = await BaseClient.PostEntities(url, JsonConvert.SerializeObject(poster)); ConfessLoader data = JsonConvert.DeserializeObject <ConfessLoader>(content); return(data); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); return(null); } }
private static List <ConfessLoader> GetConfessLoader(List <Confess> list, string key) { List <ConfessLoader> loaders = new List <ConfessLoader>(); foreach (Confess dt in list) { ConfessLoader loader = new ConfessLoader { Body = dt.Body, Category = dt.Category, Date = Shared.TimeAgo.Ago(dt.Date),// $"{dt.Date.ToLongDateString()} {dt.Date.ToShortTimeString()}", DateReal = dt.Date, DisLikes = DislikeClass.GetCount(dt.Guid, false), Likes = LikeClass.GetCount(dt.Guid, false), Guid = dt.Guid, Owner_Guid = dt.Owner_Guid, Title = dt.Title, CommentCount = CommentClass.GetCommentCount(dt.Guid), Seen = SeenClass.GetCount(dt.Guid) }; //load colors if (LikeClass.CheckExistence(dt.Guid, false, key)) { loader.LikeColorString = "#1976D2"; } if (DislikeClass.CheckExistence(dt.Guid, false, key)) { loader.DislikeColorString = "#1976D2"; } loaders.Add(loader); loader = new ConfessLoader(); } loaders = loaders.OrderByDescending(d => d.DateReal).Reverse().ToList(); return(loaders); }
private async void Delete_t_Comment(object sender, TappedRoutedEventArgs e) { if (!Logic.IsInternet()) { await new MessageDialog("No INTERNET connection has been found.").ShowAsync(); return; } MessageDialog answer = new MessageDialog("Do you want to delete this Comment?", "Confirmation"); answer.Commands.Add(new UICommand("Yes", null)); answer.Commands.Add(new UICommand("No", null)); answer.DefaultCommandIndex = 0; answer.CancelCommandIndex = 1; IUICommand cmd = await answer.ShowAsync(); if (cmd.Label == "Yes") { SymbolIcon label = (SymbolIcon)sender;; string guid = label.Tag.ToString(); try { newloader = await Online.CommentClass.DeleteComment(guid, guid); if (newloader != null) { this.DataContext = newloader; } ; LoadData(); } catch (Exception) { } await new MessageDialog("Deleted").ShowAsync(); } }
internal static void UpdateLoader(ConfessLoader incomingConfession) { Local.ConfessLoader.Update(incomingConfession); }
public async Task LeaveRoom(string confessKey, string Senderkey) { ConfessLoader confess = Store.ConfessClass.FetchOneConfessLoader(confessKey, Senderkey); await Clients.All.SendAsync("ReceiveConfession", JsonConvert.SerializeObject(confess)); }