mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 09:12:57 -07:00
The move!
This commit is contained in:
parent
1daf480b1b
commit
25526cc4d9
1147 changed files with 85 additions and 8524 deletions
82
src/Ombi.Store/Repository/SettingsJsonRepository.cs
Normal file
82
src/Ombi.Store/Repository/SettingsJsonRepository.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class SettingsJsonRepository : ISettingsRepository
|
||||
{
|
||||
public SettingsJsonRepository(IOmbiContext ctx)
|
||||
{
|
||||
Db = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
|
||||
public GlobalSettings Insert(GlobalSettings entity)
|
||||
{
|
||||
|
||||
var settings = Db.Settings.Add(entity);
|
||||
Db.SaveChanges();
|
||||
return settings.Entity;
|
||||
|
||||
}
|
||||
|
||||
public async Task<GlobalSettings> InsertAsync(GlobalSettings entity)
|
||||
{
|
||||
|
||||
var settings = await Db.Settings.AddAsync(entity).ConfigureAwait(false);
|
||||
await Db.SaveChangesAsync().ConfigureAwait(false);
|
||||
return settings.Entity;
|
||||
}
|
||||
|
||||
public IEnumerable<GlobalSettings> GetAll()
|
||||
{
|
||||
|
||||
var page = Db.Settings.ToList();
|
||||
return page;
|
||||
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GlobalSettings>> GetAllAsync()
|
||||
{
|
||||
var page = await Db.Settings.ToListAsync();
|
||||
return page;
|
||||
}
|
||||
|
||||
public GlobalSettings Get(string pageName)
|
||||
{
|
||||
return Db.Settings.FirstOrDefault(x => x.SettingsName == pageName);
|
||||
}
|
||||
|
||||
public async Task<GlobalSettings> GetAsync(string settingsName)
|
||||
{
|
||||
return await Db.Settings.FirstOrDefaultAsync(x => x.SettingsName == settingsName);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(GlobalSettings entity)
|
||||
{
|
||||
Db.Settings.Remove(entity);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(GlobalSettings entity)
|
||||
{
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public void Delete(GlobalSettings entity)
|
||||
{
|
||||
Db.Settings.Remove(entity);
|
||||
Db.SaveChanges();
|
||||
}
|
||||
|
||||
public void Update(GlobalSettings entity)
|
||||
{
|
||||
Db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue