SAB-E02/Blog.DAL/Repository/BlogRepository.cs
2021-04-06 18:04:43 +02:00

31 lines
591 B
C#

using System.Collections.Generic;
using Blog.DAL.Infrastructure;
using Blog.DAL.Model;
using System;
namespace Blog.DAL.Repository
{
public class BlogRepository
{
private readonly BlogContext _context;
public BlogRepository()
{
_context = new BlogContext();
}
public IEnumerable<Post> GetAllPosts()
{
return _context.Posts;
}
public Post add(Post post)
{
post = _context.Posts.Add(post);
_context.SaveChanges();
return post;
}
}
}