Files
LaDOSE/LaDOSE.Src/LaDOSE.Service/Service/GameService.cs
Darkstack 2fe08f938a REST to a .Net Standard Library
Test REST in discord bot and WPF
Small improvements
2019-03-16 12:22:52 +01:00

39 lines
951 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LaDOSE.Business.Interface;
using LaDOSE.Entity;
using LaDOSE.Entity.Context;
using Microsoft.EntityFrameworkCore;
namespace LaDOSE.Business.Service
{
public class GameService : BaseService<Game> ,IGameService
{
public GameService(LaDOSEDbContext context) : base(context)
{
}
public override Game AddOrUpdate(Game entity)
{
if (entity.Order == 0)
{
entity.Order = GetNextFreeOrder();
}
return base.AddOrUpdate(entity);
}
public override IEnumerable<Game> GetAll()
{
return _context.Game.Include(e => e.Seasons).ThenInclude(e=>e.Season).ToList();
}
public int GetNextFreeOrder()
{
int nextFreeOrder = _context.Game.Max(e => e.Order);
return ++nextFreeOrder;
}
}
}