public void deleteUser(string email) { using (var db = new BloggingContext()) { ChennitUser cu = db.ChennitUsers.Where(cu => cu.Email == email).FirstOrDefault(); db.ChennitUsers.Remove(cu); } }
public void createComment(int postid, string comment) { using (var db = new BloggingContext()) { ChennitUser cu = db.ChennitUsers.Where(cu => cu.ChennitUserId == CurrentUser.Id).FirstOrDefault(); cu.Comments.Add( new Comment { PostId = postid, CommentContent = comment }); db.SaveChanges(); } }
public void createPost(int blogid, string title, string content) { using (var db = new BloggingContext()) { ChennitUser user = db.ChennitUsers.Where(cu => cu.ChennitUserId == CurrentUser.Id).First(); Blog blog = db.Blogs.Where(b => b.BlogId == blogid).First(); blog.Posts.Add( new Post { ChennitUserId = user.ChennitUserId, Title = title, Content = content, Likes = 0 }); db.SaveChanges(); } }
public void createBlog(string title, string description) { Blog blog; using (var db = new BloggingContext()) { ChennitUser cu = db.ChennitUsers.Where(cu => cu.Email == CurrentUser.Email).First(); blog = new Blog { Title = title, Description = description }; cu.Blogs.Add(blog); db.SaveChanges(); } //createPost(blog.BlogId, $"Welcome to the {title} blog", "Begin blogging today!"); }