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

84 lines
1.6 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using Oqtane.Models;
namespace Oqtane.Repository
{
public class SiteRepository : ISiteRepository
{
private TenantDBContext db;
public SiteRepository(TenantDBContext context)
{
db = context;
}
public IEnumerable<Site> GetSites()
{
try
{
return db.Site.ToList();
}
catch
{
throw;
}
}
public Site AddSite(Site Site)
{
try
{
db.Site.Add(Site);
db.SaveChanges();
return Site;
}
catch
{
throw;
}
}
public Site UpdateSite(Site Site)
{
try
{
db.Entry(Site).State = EntityState.Modified;
db.SaveChanges();
return Site;
}
catch
{
throw;
}
}
public Site GetSite(int siteId)
{
try
{
return db.Site.Find(siteId);
}
catch
{
throw;
}
}
public void DeleteSite(int siteId)
{
try
{
Site site = db.Site.Find(siteId);
db.Site.Remove(site);
db.SaveChanges();
}
catch
{
throw;
}
}
}
}