vgquotes/Src/VideoGameQuotes.Web/Services/AdministrationService.cs
tmont 0dd343cc06 * flagged quote admin page
* fixed issue in user provider where if the app restarts you're still logged in but the app doesn't recognize you as such
2011-02-18 01:46:02 +00:00

35 lines
973 B
C#

using System.Collections.Generic;
using System.Linq;
using Portoa.Persistence;
using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Services {
public interface IAdministrationService {
User SaveUser(User user);
IEnumerable<Quote> GetFlaggedQuotes();
}
public class AdministrationService : IAdministrationService {
private readonly IRepository<User> userRepository;
private readonly IRepository<Quote> quoteRepository;
public AdministrationService(IRepository<User> userRepository, IRepository<Quote> quoteRepository) {
this.userRepository = userRepository;
this.quoteRepository = quoteRepository;
}
[UnitOfWork]
public User SaveUser(User user) {
return userRepository.Save(user);
}
[UnitOfWork]
public IEnumerable<Quote> GetFlaggedQuotes() {
return quoteRepository.Records
.Where(quote => quote.Flags.Any())
.ToArray()
.OrderByDescending(quote => quote.Flags.Count());
}
}
}