public IPagedList<Log> List(Page page, LogLevel level)
        {
            DateTime? before = null;

            var logLevelName = Enum.GetName(typeof(LogLevel), level);
            return Repository.Query<Log>()
                .Where(x => x.Level == logLevelName || level == LogLevel.All && (!before.HasValue || (before.HasValue && x.Date <= before)))
                .OrderByDescending(q => q.Date)
                .GetPage(page);
        }
        public void List_GetError_Page1()
        {
            // Setup dependency
            var settingsMock = new Mock<ISettings>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange
            decimal expectedResult = 10;
            string expectedName = "0";
            List<Log> logs = new List<Log>();
            DateTime startDate = DateTime.Now.AddYears(-1);
            DateTime endDate = DateTime.Now.AddYears(1);

            Page page = new Page
            {
                PageNumber = 1
            };
            LogLevel logLevel = LogLevel.Error;

            for (int i = 0; i < 20; i++)
            {
                logs.Add(new Log
                {
                    Message = i.ToString(),
                    Level = logLevel.ToString(),
                    Date = DateTime.Now
                });
            }
            repositoryMock.Setup(r => r.Query<Log>()).Returns(logs.AsQueryable());

            // Act
            LogManagementService logAdminService = new LogManagementService(
                uowMock.Object, repositoryMock.Object, settingsMock.Object);
            IPagedList<Log> currentResult = logAdminService.List(page, LogLevel.Error);

            // Assert
            Assert.AreEqual(expectedResult, currentResult.Count());
            Assert.AreEqual(expectedName, currentResult.First().Message);
        }
 public IPagedList<Profile> ListSubmitted(Page page, SubmissionState state)
 {
     throw new NotImplementedException();
 }
 //public void AddUserRole(int userId, int roleId)
 //{
 //    var role = Repositories.Role.FindById(roleId);
 //    var user = Repositories.User.FindById(userId);
 //    user.Roles.Add(role);
 //    Repositories.User.Update(user);
 //    UnitOfWork.Save();
 //}
 //public void RemoveUserFromRole(int userId, int roleId)
 //{
 //    var role = Repositories.Role.FindById(roleId);
 //    var user = Repositories.User.FindById(userId);
 //    user.Roles.Remove(role);
 //    Repositories.User.Update(user);
 //    UnitOfWork.Save();
 //}
 //public Role GetRole(string name)
 //{
 //    return Repositories.Role.GetByName(name);
 //}
 //public void SetSecurityStamp(string email, string stamp)
 //{
 //    var user = Repositories.User.GetByEmail(email);
 //    user.SecurityStamp = stamp;
 //    Repositories.User.Update(user);
 //    UnitOfWork.Save();
 //}
 //public string GetSecurityStamp(string email)
 //{
 //    return Repositories.User.GetByEmail(email).SecurityStamp;
 //}
 public IPagedList<User> List(Page page)
 {
     throw new System.NotImplementedException();
 }