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.
LOLProject/Sources/ManagersEF/EFManager.Skins.cs

77 lines
2.8 KiB

using APILOL.Mapper;
using Model;
using System.Data.SqlTypes;
namespace ManagersEF
{
public partial class EFManager
{
public class SkinsManager : ISkinsManager
{
private readonly EFManager parent;
public SkinsManager(EFManager parent)
=> this.parent = parent;
public async Task<Skin?> AddItem(Skin? item)
{
await parent.DbContext.Skin.AddAsync(item.ToEntity());
return item;
}
public async Task<bool> DeleteItem(Skin? item)
{
parent.DbContext.Skin.Remove(item.ToEntity());
return true;
}
public async Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering(
s => true,
index, count,
orderingPropertyName, descending).Select(s => s.ToModel());
}
public async Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering(
s => s.Champion.Name.Equals(champion.Name),
index, count,
orderingPropertyName, descending).Select(s => s.ToModel());
}
public async Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.GetItemsWithFilterAndOrdering(
s => s.Name.Contains(substring),
index, count,
orderingPropertyName, descending).Select(s => s.ToModel());
}
public async Task<int> GetNbItems()
{
return parent.DbContext.Skin.Count();
}
public async Task<int> GetNbItemsByChampion(Champion? champion)
{
return parent.DbContext.Skin.Where(s => s.Champion.Name.Equals(champion.Name))
.Count();
}
public async Task<int> GetNbItemsByName(string substring)
{
return parent.DbContext.Skin.Where(s => s.Name.Contains(substring))
.Count();
}
public async Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
{
parent.DbContext.Skin.Remove(oldItem.ToEntity());
parent.DbContext.Skin.Add(newItem.ToEntity());
return newItem;
}
}
}
}