private void SaveButton_Click(object sender, EventArgs e) { var editUserName = FindViewById <EditText>(Resource.Id.editText); var editComment = FindViewById <EditText>(Resource.Id.CommentEditText); if (editUserName.Text.ToString() != "" && editComment.Text.ToString() != "") { var newPost = new CommentPropertiesdb() { UserName = editUserName.Text.ToString(), Comment = editComment.Text.ToString(), Date = DateTime.Now.ToString(), Image = SelectedImage, Likes = 0 }; dbService.AddPost(newPost); List <CommentPropertiesdb> Posts = dbService.GetAllPosts().ToList(); List.Adapter = new CustomAdapterdb(this, Posts); editUserName.Text = ""; editComment.Text = ""; ImageClicks = 0; FindViewById <ImageView>(Resource.Id.ProfileImage).SetImageResource(Resource.Drawable.BlankProfile); FindViewById <TextView>(Resource.Id.CharacterLimit).Text = "character limit is 60\nPost Saved!"; } else { FindViewById <TextView>(Resource.Id.CharacterLimit).Text = "character limit is 60\nPlease Enter Comment & Username"; } }
public void CreateTable() { db.CreateTable <CommentPropertiesdb>(); var newPost = new CommentPropertiesdb(); if (db.Table <CommentPropertiesdb>().Count() == 0) { //<! --- POST ---!> newPost.UserName = "******"; newPost.Likes = 10; newPost.Image = "JamesBond"; newPost.Date = DateTime.Now.ToString(DateFormat); newPost.Comment = "“You only live twice: Once when you are born And once when you look death in the face” - Myself (James Bond)"; db.Insert(newPost); //<! --- POST ---!> newPost.UserName = "******"; newPost.Likes = 105; newPost.Image = "ElonMusk"; newPost.Date = DateTime.Now.ToString(DateFormat); newPost.Comment = "Used to live in Silicon Valley, now I live in Silicone Valley"; db.Insert(newPost); } ; }
public void AddPost(CommentPropertiesdb Post) { db.Insert(Post); }
public void DeletePost(CommentPropertiesdb Post2Delete) { CreateDatabase(); db.Delete <CommentPropertiesdb>(Post2Delete.Id); }