public User Login(string userName)
        {
            User user = _userRepository.First(u => u.Login == userName || u.Email == userName);

            if (user != null)
            {
                CreateCookie(userName);
            }

            return(user);
        }
示例#2
0
        public override IEnumerable <Genre> Get(string cultureCode, params Expression <Func <Genre, object> >[] includeProperties)
        {
            var genres = base.Get(cultureCode, includeProperties).ToList();

            foreach (var genre in genres)
            {
                LocalizationProvider.Localize(genre, cultureCode);
                if (genre.ParentGenreId != null)
                {
                    genre.ParentGenreName = LocalizationProvider.Localize(_genreRepository.First(g => g.Id == genre.ParentGenreId), cultureCode).Name;
                }
            }

            return(genres);
        }
示例#3
0
 private void Init(string name, IGenericDataRepository <UserEntity, User> userRepository)
 {
     if (!string.IsNullOrEmpty(name))
     {
         User = userRepository.First(u => u.Login == name || u.Id == name || u.Email == name);
     }
 }
示例#4
0
        public virtual TDomain First(Expression <Func <TDomain, bool> > filter, string cultureCode)
        {
            var item = _genericRepository.First(filter);

            LocalizationProvider.Localize(item, cultureCode);
            return(item);
        }
示例#5
0
        public Publisher GetPublisherByCompanyName(string companyName, string cultureCode)
        {
            var company = _publisherRepository.First(x => x.CompanyName == companyName);

            LocalizationProvider.Localize(company, cultureCode);

            return(company);
        }
示例#6
0
        public string Login(string userName, string password, bool isPersistent)
        {
            var hashedPassword = _generator.Generate(password);
            var user           = _userRepository.First(u => (u.Login == userName || u.Email == userName) && u.Password == password);

            if (user == null)
            {
                return(null);
            }

            User = new UserProvider(userName, _userRepository);
            var encryptedTicket = CreateTicket(user.Id, isPersistent);

            return(encryptedTicket);
        }
        public virtual TDomain First(Expression <Func <TDomain, bool> > filter)
        {
            var domain = SqlDataRepository.First(filter) ?? MongoDataRepository.First(filter);

            return(domain);
        }