You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
using API_LoL_Project.Mapper;
|
|
using API_LoL_Project.Mapper.API_LoL_Project.Mapper;
|
|
using Model;
|
|
using Shared;
|
|
|
|
namespace Business
|
|
{
|
|
public partial class DbData
|
|
{
|
|
public class RunesManager : IRunesManager
|
|
{
|
|
private readonly DbData parent;
|
|
|
|
public RunesManager(DbData parent)
|
|
=> this.parent = parent;
|
|
public async Task<Rune?> AddItem(Rune? item)
|
|
{
|
|
await parent.DbContext.runes.AddAsync(item.ToEntity());
|
|
return item;
|
|
}
|
|
|
|
public async Task<bool> DeleteItem(Rune? item)
|
|
{
|
|
parent.DbContext.runes.Remove(item.ToEntity());
|
|
return true;
|
|
}
|
|
|
|
public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
{
|
|
return parent.DbContext.runes.GetItemsWithFilterAndOrdering(
|
|
r => true,
|
|
index, count,
|
|
orderingPropertyName, descending).Select(r => r.ToModel());
|
|
}
|
|
|
|
public async Task<IEnumerable<Rune?>> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
{
|
|
return parent.DbContext.runes.GetItemsWithFilterAndOrdering(
|
|
r => r.RuneFamily.Equals(family),
|
|
index, count,
|
|
orderingPropertyName, descending).Select(r => r.ToModel());
|
|
}
|
|
|
|
public async Task<IEnumerable<Rune?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
|
|
{
|
|
return parent.DbContext.runes.GetItemsWithFilterAndOrdering(
|
|
r => r.Name.Contains(substring),
|
|
index, count,
|
|
orderingPropertyName, descending).Select(r => r.ToModel());
|
|
}
|
|
|
|
public async Task<int> GetNbItems()
|
|
{
|
|
return parent.DbContext.runes.Count();
|
|
}
|
|
|
|
public async Task<int> GetNbItemsByFamily(RuneFamily family)
|
|
{
|
|
return parent.DbContext.runes.Where(r => r.RuneFamily.Equals(family)).Count();
|
|
}
|
|
|
|
public async Task<int> GetNbItemsByName(string substring)
|
|
{
|
|
return parent.DbContext.runes.Where(r => r.Name.Contains(substring)).Count();
|
|
}
|
|
|
|
public async Task<Rune?> UpdateItem(Rune? oldItem, Rune? newItem)
|
|
{
|
|
parent.DbContext.runes.Remove(oldItem.ToEntity());
|
|
parent.DbContext.runes.Add(newItem.ToEntity());
|
|
return newItem;
|
|
}
|
|
}
|
|
}
|
|
}
|