vgquotes/Src/VideoGameQuotes.Web/Services/SystemService.cs

31 lines
896 B
C#

using System.Collections.Generic;
using System.Linq;
using Portoa.Persistence;
using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Services {
public interface ISystemService {
IEnumerable<GamingSystem> FindByNameOrAbbreviation(string name, string abbreviation);
GamingSystem Save(GamingSystem system);
}
public class SystemService : ISystemService {
private readonly IRepository<GamingSystem> repository;
public SystemService(IRepository<GamingSystem> repository) {
this.repository = repository;
}
[UnitOfWork]
public IEnumerable<GamingSystem> FindByNameOrAbbreviation(string name, string abbreviation) {
return repository
.Records
.Where(system => system.Abbreviation == abbreviation || system.Name == name);
}
[UnitOfWork]
public GamingSystem Save(GamingSystem system) {
return repository.Save(system);
}
}
}