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 static async void PushToEveryone(Confess confess) { string newbody = ""; if (confess.Body.Length > 35) { newbody = $"{confess.Body.Substring(0, 30)}..."; } else { newbody = confess.Body; } PushToAll dataToPush = new PushToAll() { notification_content = new NotificationContent() { title = "New Confession 📢!", body = confess.Body, name = Guid.NewGuid().ToString().Replace("-", ""), custom_data = new Dictionary <string, string> { { "key1", confess.Guid }, { "key2", confess.Owner_Guid }, { "type", "Confession" }, { "sender", confess.Owner_Guid } } } }; await PushToServer(dataToPush); }
public async Task <IActionResult> Update(Modeller confessed) { Confess confess = confessed.Confess; try { if (string.IsNullOrWhiteSpace(confess.Title) || string.IsNullOrWhiteSpace(confess.Body) || string.IsNullOrWhiteSpace(confess.Category)) { return(RedirectToActionPermanent($"Edit/{confess.Guid}", "Home")); } Confess fetch = await Store.ConfessClass.FetchOneConfessByGuid(confess.Guid, GetToken(GetKey())); fetch.Title = confess.Title; fetch.Body = confess.Body; fetch.Category = confess.Category; //Save await Store.ConfessClass.UpdateConfess(fetch, GetToken(GetKey())); return(RedirectToActionPermanent($"Edit/{confess.Guid}", "Home")); } catch (Exception) { return(RedirectToActionPermanent($"Edit/{confess.Guid}", "Home")); } }
private async void UpdateButton_Clicked(object sender, EventArgs e) { if (!Logic.IsInternet()) { DependencyService.Get <IMessage>().ShortAlert(Constants.No_Internet); return; } if (string.IsNullOrEmpty(title.Text)) { DependencyService.Get <IMessage>().ShortAlert("Please type a Title"); return; } if (cat.SelectedItem == null) { DependencyService.Get <IMessage>().ShortAlert("Please choose a Category"); return; } if (string.IsNullOrEmpty(body.Text)) { DependencyService.Get <IMessage>().ShortAlert("Please type a Body"); return; } if (title.Text.Length > 50) { DependencyService.Get <IMessage>().ShortAlert("The Title is rather too long"); return; } if (body.Text.Length < 100) { DependencyService.Get <IMessage>().ShortAlert("Please type more texts for the Body"); return; } ChangeLoading(true); await Task.Delay(10); try { Confess fetch = new Confess { Guid = confess.Guid, Title = title.Text, Body = body.Text, Category = cat.SelectedItem.ToString() }; //Update MessagingCenter.Send <object, Confess>(this, Constants.update_confession, fetch); //await Store.ConfessClass.UpdateConfess(fetch); ChangeLoading(false); //close this page await Navigation.PopModalAsync(); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); } }
private async void CreateButton_Clicked(object sender, EventArgs e) { if (!Logic.IsInternet()) { DependencyService.Get <IMessage>().ShortAlert(Constants.No_Internet); return; } if (string.IsNullOrWhiteSpace(title.Text.Trim())) { DependencyService.Get <IMessage>().ShortAlert("Please type a Title"); return; } if (cat.SelectedItem == null) { DependencyService.Get <IMessage>().ShortAlert("Please choose a Category"); return; } if (string.IsNullOrWhiteSpace(body.Text)) { DependencyService.Get <IMessage>().ShortAlert("Please type a Body"); return; } if (title.Text.Length > 50) { DependencyService.Get <IMessage>().ShortAlert("The Title is rather too long"); return; } if (body.Text.Length < 100) { DependencyService.Get <IMessage>().ShortAlert("Please type more texts for the Body"); return; } try { ChangeLoading(true); Confess confess = new Confess() { Title = title.Text.Trim(), Body = body.Text.Trim(), Category = cat.SelectedItem.ToString(), Owner_Guid = await Logic.GetKey(), }; //Send to Confession Model MessagingCenter.Send <object, Confess>(this, Constants.send_confession, confess); DependencyService.Get <IMessage>().ShortAlert("Queued for Sending"); ChangeLoading(false); //close this page await Navigation.PopModalAsync(); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); ChangeLoading(false); } }
public ActionResult Edit(int id) { if (iConfess.GetDetail(id).MemberID.ToString() == User.Identity.Name) { Confess confess = iConfess.GetDetail(id); return(View(confess)); } return(View("~/Views/Common/Denied.cshtml")); }
public static async Task CreateConfess(Confess confess) { try { string url = "confess/add"; string content = await BaseClient.PostEntities(url, JsonConvert.SerializeObject(confess)); } catch (Exception) { } }
public static async Task UpdateConfess(Confess confess, string token) { try { string url = "confess/update"; string content = await BaseClient.PutEntities(url, JsonConvert.SerializeObject(confess), token); } catch (Exception ex) { } }
public static async Task UpdateConfess(Confess confess) { try { string url = "confess/update"; string content = await BaseClient.PutEntities(url, JsonConvert.SerializeObject(confess)); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); } }
private async void Add_Tapped(object sender, RoutedEventArgs e) { if (!Logic.IsInternet()) { await new MessageDialog("No INTERNET connection has been found.").ShowAsync(); return; } if (string.IsNullOrEmpty(title_text.Text)) { await new MessageDialog("Please type a Title").ShowAsync(); return; } if (categories.SelectedItem == null) { await new MessageDialog("Please choose a Category").ShowAsync(); return; } if (string.IsNullOrEmpty(body_text.Text)) { await new MessageDialog("Please type a Body").ShowAsync(); return; } if (body_text.Text.Length < 100) { await new MessageDialog("Please type more texts for the Body").ShowAsync(); return; } try { ChangeLoading(true); Confess confess = new Confess() { Title = title_text.Text, Body = body_text.Text, Category = categories.SelectedItem.ToString(), Owner_Guid = Logic.GetKey(), }; //Save await Online.ConfessClass.CreateConfess(confess); await new MessageDialog("Published").ShowAsync(); ChangeLoading(false); //call the mainpage to reload the list and refresh Frame.Navigate(typeof(Homer)); } catch (Exception ex) { ChangeLoading(false); } }
public static void UpdateConfess(Confess incoming) { Confess confes = contextLite.Confess.FindOne(d => d.Guid == incoming.Guid); confes.Title = incoming.Title; confes.Body = incoming.Body; confes.Category = incoming.Category; contextLite.Confess.Update(confes); // FilterDefinition<Confess> filter = Builders<Confess>.Filter.Eq(u => u.Guid, confess.Guid); // context.Confess.ReplaceOne(filter, confess); }
public static bool Email(Confess confess) { string Url = string.Format("http://www.justsay.cn/confess/Details/{0}", confess.ID); string msg = SMTPManager.MailSending(confess.ToEmail, confess.ToName + "你被人表白了", string.Format(ConfessEmailTemplete, confess.ToName, confess.Content, Url), "", 0); if (msg != "发送成功") { ToDoListBusiness.WriteLog(msg, "邮箱异常", "SMTPManager.MailSending", true); return(false); } return(true); }
public ActionResult Create([Bind(Include = "Content,Message,ToEmail,ToPhone,ToName,ImgUrl,FlashUrl,MusicUrl,ViewName")] Confess confess) { IMemberBusiness iMember = new MemberBusiness(new JustSayEntities()); if (iMember.IsLimitPost(User.Identity.Name.ToInt())) { ViewData["Validate"] = true; } else { ModelState.Remove("_mvcCaptchaText"); } if (ModelState.IsValid) { iConfess.Add(confess); // IMemberBusiness iMember = new MemberBusiness(new JustSayEntities()); confess.Member = iMember.GetDetail(Convert.ToInt32(User.Identity.Name)); Relation relation = new Relation { FromEmail = confess.Member.Email, ShowName = confess.Member.ShowName, MemberID = confess.Member.ID, FromPhone = confess.Member.Phone, FromName = confess.Member.RealName, ToEmail = confess.ToEmail, ToName = confess.ToName, ToPhone = confess.ToPhone, }; ViewBag.IsEmailSuccess = Inform.Email(confess); ViewBag.IsSMSSuccess = false; ViewBag.IsSMSMsg = ""; if (!string.IsNullOrEmpty(confess.ToPhone)) { if (confess.Member.Score > 50) { ViewBag.IsSMSSuccess = Inform.SMS(confess); confess.Member.Score -= 50; ViewBag.IsSmsSuccess = true; } else { ViewBag.IsSMSMsg = "节操币不足50,请多发贴,多回贴"; } } ViewData["ConfessID"] = confess.ID; return(View("~/Views/Relation/Create.cshtml", relation)); } return(View(confess)); }
public static bool SMS(Confess confess) { string Url = string.Format("http://www.justsay.cn/confess/Details/{0}", confess.ID); SmsStatus status = SMSHelper.SendMsg(confess.ToPhone, string.Format(ConfessSMSTemplete, confess.ToName, Url)); if (!status.IsSuccess) { ToDoListBusiness.WriteLog(status.ErrorMessage, "短信异常", "SMSHelper.SendMsg", true); return(false); } return(status.IsSuccess); // return true; }
//public IActionResult Edit() //{ // ViewData["Message"] = "Your contact page."; // return View(); //} public async Task <IActionResult> Edit() { string guid = Request.Path.Value.Split('/').LastOrDefault(); if (!string.IsNullOrEmpty(guid)) { Confess confess = await Store.ConfessClass.FetchOneConfessByGuid(guid, GetToken(GetKey())); Modeller modeller = new Modeller() { Confess = confess, ListItems = Logic.GetCategoriesLists(confess.Category) }; return(View(modeller)); } return(View()); }
public ActionResult <Confess> FetchByGuid(string guid) { try { //prepare responses Confess response = Store.ConfessClass.FetchOneConfessByGuid(guid); //return data return(Ok(response)); } catch (Exception ex) { return(new Confess() { }); } }
public static async Task <Confess> FetchOneConfessByGuid(string guid, string token) { try { string url = $"confess/fetch/guid?guid={guid}"; string content = await BaseClient.GetEntities(url, token); Confess data = JsonConvert.DeserializeObject <Confess>(content); return(data); } catch (Exception ex) { return(new Confess() { }); } }
public static async Task <Confess> FetchOneConfessByGuid(string guid) { try { string url = $"confess/fetch/guid?guid={guid}"; string content = await BaseClient.GetEntities(url); Confess data = JsonConvert.DeserializeObject <Confess>(content); return(data); } catch (Exception ex) { Crashes.TrackError(ex, Logic.GetErrorProperties(ex)); return(new Confess() { }); } }
public static List <CommentLoader> FetchComment(string guid, string key) { List <Comment> data = contextLite.Comment.Find(d => d.Confess_Guid == guid).ToList(); //FilterDefinitionBuilder<Comment> builder = Builders<Comment>.Filter; //FilterDefinition<Comment> idFilter = builder.Eq(e => e.Confess_Guid, guid); //IFindFluent<Comment, Comment> cursor = context.Comment.Find(idFilter); // Find All //report seen Confess confess = ConfessClass.FetchOneConfessByGuid(guid); if (confess.Owner_Guid != key) { SeenClass.Post(guid, key); } return(GetLoader(data, key)); }
public ActionResult Edit([Bind(Include = "ID,Content,Message,ViewName")] Confess confess) { Confess oconfess = iConfess.GetDetail(confess.ID); if (oconfess.MemberID.ToString() == User.Identity.Name) { ModelState.Remove("ToEmail"); if (ModelState.IsValid) { oconfess.Content = confess.Content; oconfess.Message = confess.Message; oconfess.ViewName = confess.ViewName; iConfess.Update(oconfess); return(RedirectToAction("Details", new { id = confess.ID })); } return(View(confess)); } return(View("~/Views/Common/Denied.cshtml")); }
public static ConfessLoader FetchOneConfessLoader(string guid, string senderKey) { Confess data = FetchOneConfessByGuid(guid); //report seen if (data.Owner_Guid != senderKey) { SeenClass.Post(guid, senderKey); } // contextLite.Confess.FindOne(d => d.Guid == guid); //FilterDefinitionBuilder<Confess> builder = Builders<Confess>.Filter; //FilterDefinition<Confess> idFilter = builder.Eq(e => e.Guid, guid); //IFindFluent<Confess, Confess> cursor = context.Confess.Find(idFilter); // Find All return(GetConfessLoader(data, senderKey)); }
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 ActionResult Update([FromBody] Confess data) { try { bool isSafe = Logic.CheckSpamFree(data.Body.ToLower()); if (isSafe) { Store.ConfessClass.UpdateConfess(data); } else { Push.NotifyOwnerOFSpam(data.Owner_Guid); } return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex.ToString())); } }
public async Task <IActionResult> Add(Modeller confessed) { try { Confess confess = confessed.Confess;// new Confess();// (Confess)confessed; if (string.IsNullOrWhiteSpace(confess.Title) || string.IsNullOrWhiteSpace(confess.Body) || string.IsNullOrWhiteSpace(confess.Category)) { return(RedirectToActionPermanent("Index", "Home")); } confess.Owner_Guid = GetKey(); //Save await Store.ConfessClass.CreateConfess(confess, GetToken(GetKey())); return(RedirectToActionPermanent("Index", "Home")); } catch (Exception) { return(RedirectToActionPermanent("Index", "Home")); } }
public static void CreateConfess(Confess confess) { confess.Id = Logical.Setter(confess.Id); contextLite.Confess.Insert(confess); //context.Confess.InsertOne(confess); }
public static void CreateConfess(Confess Confess) { contextLite.Confess.Insert(Confess); }
private async void Update_Tapped(object sender, RoutedEventArgs e) { if (!Logic.IsInternet()) { await new MessageDialog("No INTERNET connection has been found.").ShowAsync(); return; } ChangeLoading(true); if (string.IsNullOrEmpty(title_text.Text)) { await new MessageDialog("Please type a Title").ShowAsync(); ChangeLoading(false); return; } if (categories.SelectedItem == null) { await new MessageDialog("Please choose a Category").ShowAsync(); ChangeLoading(false); return; } if (string.IsNullOrEmpty(body_text.Text)) { await new MessageDialog("Please type a Body").ShowAsync(); ChangeLoading(false); return; } if (body_text.Text.Length < 100) { await new MessageDialog("Please type more texts for the Body").ShowAsync(); return; } try { Confess fetch = new Confess { Title = title_text.Text, Body = body_text.Text, Category = categories.SelectedItem.ToString(), Guid = confess.Guid }; //Save await Online.ConfessClass.UpdateConfess(fetch); await new MessageDialog("Updated").ShowAsync(); ChangeLoading(false); //close this page if (Frame.CanGoBack) { Frame.GoBack(); } else { Frame.Navigate(typeof(Homer)); } } catch (Exception) { } }