oqtane.framework/Oqtane.Server/Repository/PageRepository.cs
2019-08-20 16:43:35 -04:00

96 lines
1.9 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using Oqtane.Models;
namespace Oqtane.Repository
{
public class PageRepository : IPageRepository
{
private TenantDBContext db;
public PageRepository(TenantDBContext context)
{
db = context;
}
public IEnumerable<Page> GetPages()
{
try
{
return db.Page.ToList();
}
catch
{
throw;
}
}
public IEnumerable<Page> GetPages(int SiteId)
{
try
{
return db.Page.Where(item => item.SiteId == SiteId).ToList();
}
catch
{
throw;
}
}
public Page AddPage(Page Page)
{
try
{
db.Page.Add(Page);
db.SaveChanges();
return Page;
}
catch
{
throw;
}
}
public Page UpdatePage(Page Page)
{
try
{
db.Entry(Page).State = EntityState.Modified;
db.SaveChanges();
return Page;
}
catch
{
throw;
}
}
public Page GetPage(int PageId)
{
try
{
return db.Page.Find(PageId);
}
catch
{
throw;
}
}
public void DeletePage(int PageId)
{
try
{
Page Page = db.Page.Find(PageId);
db.Page.Remove(Page);
db.SaveChanges();
}
catch
{
throw;
}
}
}
}