示例#1
0
        public async Task CreatePost(MyProfileViewModel viewModel)
        {
            var post = new Post
            {
                UserId  = viewModel.CreatePost.UserId,
                Title   = viewModel.CreatePost.Title,
                WallId  = viewModel.CreatePost.WallId,
                Content = viewModel.CreatePost.Content,
            };

            await dbContext.AddAsync(post);

            await dbContext.SaveChangesAsync();
        }
示例#2
0
        public async Task CreatePost(MyProfileViewModel viewModel)
        {
            var post = new Post
            {
                UserId  = viewModel.CreatePost.UserId,
                Title   = viewModel.CreatePost.Title,
                Content = viewModel.CreatePost.Content,
            };

            await dbContext.AddAsync(post);

            try
            {
                await dbContext.SaveChangesAsync();
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }