Пример #1
0
        public string Create(PostModel postModel)
        {
            Post post = new Post()
            {
                Id = postModel.Id, Name = postModel.Name, MakeBy = postModel.MakeBy, MakeDate = postModel.MakeDate
            };

            db.Posts.Add(post);
            db.SaveChanges();

            return(post.Id);
        }
Пример #2
0
        public string Create(CommentModel commentModel)
        {
            Comment comment = new Comment()
            {
                Id = commentModel.Id, Name = commentModel.Name, PostId = commentModel.PostId, UpVote = commentModel.UpVote, DownVote = commentModel.DownVote, MakeBy = commentModel.MakeBy, MakeDate = commentModel.MakeDate
            };

            db.Comments.Add(comment);
            db.SaveChanges();

            return(comment.Id);
        }