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 repository; public PublisherService(IRepository 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); } } }