예제 #1
0
        public async Task RemoveById(int id)
        {
            var post = new Enities.Post()
            {
                Id = id
            };

            _cmsDbContext.Posts.Attach(post);
            _cmsDbContext.Posts.Remove(post);
            await _cmsDbContext.SaveChangesAsync();
        }
예제 #2
0
        public async Task <Core.Domain.Post> Add(Core.Domain.Post domain)
        {
            var post = new Enities.Post
            {
                Title        = domain.Title,
                CreatedDate  = domain.CreatedDate,
                ModifiedDate = domain.ModifiedDate,
                Content      = domain.Content
            };

            await _cmsDbContext.Posts.AddAsync(post);

            await _cmsDbContext.SaveChangesAsync();

            return(new Core.Domain.Post
            {
                Content = post.Content,
                ModifiedDate = post.ModifiedDate,
                Title = post.Title,
                CreatedDate = post.CreatedDate,
                Id = post.Id
            });
        }