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

31 lines
773 B
C#
Raw Normal View History

using System.Linq;
using JetBrains.Annotations;
using Portoa.Persistence;
using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Services {
public interface IPublisherService {
[CanBeNull]
Publisher FindByName(string name);
Publisher Save(Publisher publisher);
}
public class PublisherService : IPublisherService {
private readonly IRepository<Publisher> repository;
public PublisherService(IRepository<Publisher> repository) {
this.repository = repository;
}
[UnitOfWork]
public Publisher FindByName(string name) {
return repository.Records.FirstOrDefault(publisher => publisher.Name == name);
}
[UnitOfWork]
public Publisher Save(Publisher publisher) {
return repository.Save(publisher);
}
}
}