Пример #1
0
        public async Task PostBlog(Blog blog, DateTime tsStamp, string usStamp, string asStamp)
        {
            PostLogic postLogic = new PostLogic(_context);

            blog.SetBaseData(tsStamp, usStamp, asStamp);
            _context.Entry(blog).State = EntityState.Added;

            await _context.SaveChangesAsync();

            await postLogic.PostPosts(blog.Posts, tsStamp, usStamp, asStamp);
        }
Пример #2
0
        public async Task <Blog> DeleteBlog(int id)
        {
            var blog = await _context.Blog.FindAsync(id);

            _context.Blog.Remove(blog);
            await _context.SaveChangesAsync();

            PostLogic postLogic = new PostLogic(_context);
            await postLogic.Delete(id);

            return(blog);
        }
Пример #3
0
        public async Task PutBlog(Blog blog, DateTime tsStamp, string usStamp, string asStamp)
        {
            PostLogic postLogic = new PostLogic(_context);

            blog.SetBaseData(tsStamp, usStamp, asStamp);
            _context.Entry(blog).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                await postLogic.PutPosts(blog.Posts, tsStamp, usStamp, asStamp);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }