<|start_filename|>Server/Repository/BlogRepository.cs<|end_filename|>
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections.Generic;
using Oqtane.Modules;
using Oqtane.Blogs.Models;

namespace Oqtane.Blogs.Repository
{
    public class BlogRepository : IBlogRepository, IService
    {
        private readonly BlogContext _db;

        public BlogRepository(BlogContext context)
        {
            _db = context;
        }

        public IEnumerable<Blog> GetBlogs(int ModuleId)
        {
            return _db.Blog.Where(item => item.ModuleId == ModuleId);
        }

        public Blog GetBlog(int BlogId)
        {
            return _db.Blog.Find(BlogId);
        }

        public Blog AddBlog(Blog Blog)
        {
            _db.Blog.Add(Blog);
            _db.SaveChanges();
            return Blog;
        }

        public Blog UpdateBlog(Blog Blog)
        {
            _db.Entry(Blog).State = EntityState.Modified;
            _db.SaveChanges();
            return Blog;
        }

        public void DeleteBlog(int BlogId)
        {
            Blog Blog = _db.Blog.Find(BlogId);
            _db.Blog.Remove(Blog);
            _db.SaveChanges();
        }
    }
}


<|start_filename|>Server/Repository/IBlogRepository.cs<|end_filename|>
using System.Collections.Generic;
using Oqtane.Blogs.Models;

namespace Oqtane.Blogs.Repository
{
    public interface IBlogRepository
    {
        IEnumerable<Blog> GetBlogs(int ModuleId);
        Blog GetBlog(int BlogId);
        Blog AddBlog(Blog Blog);
        Blog UpdateBlog(Blog Blog);
        void DeleteBlog(int BlogId);
    }
}


<|start_filename|>Client/Services/IBlogService.cs<|end_filename|>
using System.Collections.Generic;
using System.Threading.Tasks;
using Oqtane.Blogs.Models;

namespace Oqtane.Blogs.Services
{
    public interface IBlogService 
    {
        Task<List<Blog>> GetBlogsAsync(int ModuleId);

        Task<Blog> GetBlogAsync(int BlogId, int ModuleId);

        Task<Blog> AddBlogAsync(Blog Blog);

        Task<Blog> UpdateBlogAsync(Blog Blog);

        Task DeleteBlogAsync(int BlogId, int ModuleId);
    }
}


<|start_filename|>Client/AssemblyInfo.cs<|end_filename|>
﻿using System.Resources;
using Microsoft.Extensions.Localization;

[assembly: RootNamespace("Oqtane.Blogs.Client")]
