public UserDto CheckUser(string userName, string password) { _logger.LogInformation("CheckUser: username:{0}", userName); if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password)) { return(null); } //get from indexs,get radom id to get url for balanced solrcloud var readindex = _indexReadFactory.CreateIndex <UserIndexs, IUserIndexsIndexRead>(Guid.NewGuid().ToString(), "authcore1"); var userindexs = readindex.FirstOrDefault(new List <KeyValuePair <string, string> >(2) { new KeyValuePair <string, string>("name", userName), new KeyValuePair <string, string>("keywords", password) }); UserIndex userindex = null; if (userindexs == null) { userindex = _userrepositoryread.CheckUserIndex(userName, password); if (userindex != null)//write to indexs { var writeuserindexs = Mapper.Map <UserIndexs>(userindex); var writeindex = _indexFactory.CreateIndex <UserIndexs, IUserIndexsIndex>(writeuserindexs.Id.ToString(), "authcore1"); writeindex.Insert(writeuserindexs); } } else { userindex = Mapper.Map <UserIndex>(userindexs); } var user = _repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(userindex.UserId.ToString()).CheckUser(userName, password);// return(Mapper.Map <UserDto>(user)); }
public UserDto Get(Guid id) { if (id == null) { return(null); } return(_cacheService.Cached.Get(() => { return Mapper.Map <UserDto>(_repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(id.ToString()).Get(id)); }, $"{CacheKeyName.UserKey}{id}")); //return rlist.FirstOrDefault(x => x.Id == id); // return Mapper.Map<UserDto>(_repositoryReadFactory.CreateUserRepositoryRead(id.ToString()).Get(id)); }
public UserDto Get(Guid id) { if (id == null) { return(null); } return(_cacheService.Cached.Get(() => { return Mapper.Map <UserDto>(_repositoryReadFactory.CreateRepository <User, IUserRepositoryRead>(id.ToString()).Get(id)); }, $"{CacheKeyName.CRMUserKey}{id}")); }