public void WordServiceTest_Get_count() { var expected = rep.GetAll().Count(); var actual = service.GetAll().Count(); Assert.AreEqual(expected, actual); }
public Word Next(Guid userId) { var allWords = _wordRepository.GetAll(userId); if (allWords == null) { return(null); } var stacks = allWords.GroupBy(x => x.TrainingHistories.Count(y => y.IsCorrect)).OrderBy(x => x.Key); Word wordReadyForTraining = null; DateTime olderDate = DateTime.MaxValue; foreach (var stack in stacks) { foreach (var word in stack) { if (IsReadyForTraining(word, stack.Key)) { if ((word.LastTraining == null && word.AddedDateTime < olderDate)) { wordReadyForTraining = word; olderDate = word.AddedDateTime; } else if (word.LastTraining != null && word.LastTraining < olderDate) { wordReadyForTraining = word; olderDate = word.LastTraining.Value; } } } } return(wordReadyForTraining); }
public void WordRepositoryTest_Words_count() { var count = context.Object.Words.Count(); var rep_count = rep.GetAll().Count(); Assert.AreEqual(count, rep_count, string.Format(count + " != " + rep_count)); }
public IActionResult GetAll([FromQuery] WordQueryUrl query) { var item = _repository.GetAll(query); if (item.Results.Count == 0) { return(StatusCode(404)); } PaginationList <WordDTO> List = CreateLinksListWordDTO(query, item); return(Ok(List)); }
// // GET: /Words/ public ViewResult Index(int page = 1, string like = "") { if (!UserHelper.GetCurrent().IsAdmin) { return(View("AccesoDenegdo")); } IList <Word> list = _wordRepository.GetAll().Where(x => x.Name.StartsWith(like)).ToList(); var model = new CrudViewModel <Word>(list, page, 20); model.Filter = like; return(View(model)); }
private IList <WordViewModel> GetRandomWords(Word except, int amount) { var allWords = _wordRepository.GetAll(except.UserId).Except(new List <Word> { except }).ToList(); if (allWords.Count <= amount) { return(allWords.Select(x => new WordViewModel(x)).ToList()); } return(allWords.Shuffle().Take(amount).Select(x => new WordViewModel(x)).ToList()); }
public IQueryable <Word> GetAll() { return(rep.GetAll()); }
public List <Word> GetAllWords() { return(_wordRepository.GetAll()); }
public async Task <IActionResult> StartGame(Room room) { var wordCount = await _wordRepository.CountAll(); Random rnd = new Random(); var randomWord = rnd.Next(0, wordCount); var data = await _wordRepository.GetAll(); var word = data.ToList()[randomWord]; StringBuilder firstHint = new StringBuilder(); for (int i = 0; i < word.WordName.Length; i++) { firstHint.Append("_"); } var secondHintNumber = rnd.Next(0, word.WordName.Length); StringBuilder secondHint = new StringBuilder(); for (int i = 0; i < word.WordName.Length; i++) { if (i != secondHintNumber) { secondHint.Append("_"); } else { secondHint.Append($"{word.WordName[secondHintNumber]} "); } } var thirdHintNumber = rnd.Next(0, word.WordName.Length); var thirdHint = secondHint.ToString(); if (thirdHint.ToString()[thirdHintNumber] != '_') { thirdHint.Remove(thirdHintNumber, 1); thirdHint.Insert(thirdHintNumber, word.WordName[thirdHintNumber].ToString()); } else {//PROBLEM thirdHintNumber = rnd.Next(0, word.WordName.Length); thirdHint.Remove(thirdHintNumber, 1); thirdHint.Insert(thirdHintNumber, word.WordName[thirdHintNumber].ToString()); } var roomPlayerList = JsonConvert.DeserializeObject <List <ConnectedUser> >(await _redisHandler.GetFromCache("Userlist:ConnectedUser")).Where(x => x.ConnectedRoomName == room.roomName).ToList(); var shuffledList = ShuffleList(roomPlayerList); await _redisHandler.AddToCache($"Room:StartedGame:{room.roomName}", TimeSpan.FromMinutes(10), JsonConvert.SerializeObject(new StartedGame { word = word, firstHint = firstHint.ToString(), secondHint = secondHint.ToString(), thirdHint = thirdHint, userList = shuffledList, point = 30, turn = 1 })); await _hubContext.Clients.Group(room.roomName).SendAsync("GameTurn", new { wordName = word.WordName, turn = 1, firstHint = firstHint.ToString(), secondHint = secondHint.ToString() }); await _hubContext.Clients.Client(shuffledList[0].ConnectionId).SendAsync("YourTurn", true); await _hubContext.Clients.Group(room.roomName).SendAsync("StartTurnTimer", true); return(await Task.FromResult(Ok())); }
// GET: Word public ActionResult Index() { return(View(_wordRepository.GetAll())); }
public IActionResult GetAll() { _log.LogInformation("Get all words"); return Ok(_wordRepository.GetAll(UserId).Select(x => new WordViewModel(x))); }
public ICollection <Word> GetAll() { var results = _repository.GetAll(); return(results); }