コード例 #1
0
 public void deleteUser(string email)
 {
     using (var db = new BloggingContext())
     {
         ChennitUser cu = db.ChennitUsers.Where(cu => cu.Email == email).FirstOrDefault();
         db.ChennitUsers.Remove(cu);
     }
 }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
        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!");
        }