public void UpdateCurrentLevel() { ResetScene(); countOnCurrentLevel++; if (countOnCurrentLevel == 5) { countOnCurrentLevel = 0; int levelNo = currentLevel.levelNum; if (levelNo >= ConfigData.NumberOfLevels) { sceneHandler.GoGameOverScene(); } levelNo++; // Next Level LevelDTO newLevelDTO = ConfigData.LevelData.Levels.Find(it => it.LevelNo == levelNo); CurrentLevel.LevelNo = newLevelDTO.LevelNo; CurrentLevel.Difficulty = newLevelDTO.Difficulty.ToDifficulty();; CurrentLevel.Numbers = newLevelDTO.Numbers; CurrentLevel.Operators = newLevelDTO.Operators.Select(it => it.ToOperator()).ToList(); CurrentLevel.NoNumbers = newLevelDTO.NoNumbers; CurrentLevel.NoQuestions = newLevelDTO.NoQuestions; CurrentLevel.NoBlanks = newLevelDTO.NoBlanks; } currentLevel = GenerateLevel(); SetupLevel(ref currentLevel); }
public Activity(LevelDTO levelDTO) { this.levelDTO = levelDTO; foreach (var item in CurrentStatsInfo.ActivityImagesList) { if (item.name == levelDTO.code + ConstantClass.IMAGE_TYPE_ICON) { activitySprites.iconSprite = item; break; } } foreach (var item in CurrentStatsInfo.ActivityImagesList) { if (item.name == levelDTO.code + ConstantClass.IMAGE_TYPE_THUMB) { activitySprites.thumbSprite = item; break; } } if (activitySprites.iconSprite == null) { //Debug.Log("ICON SPRITE NOT FOUND: " + levelDTO.code + ConstantClass.IMAGE_TYPE_ICON); } if (activitySprites.thumbSprite == null) { //Debug.Log("THUMBNAIL SPRITE NOT FOUND: " + levelDTO.code + ConstantClass.IMAGE_TYPE_THUMB); } }
public void UpdateLevel_ShouldCallService_AndReturn200WithDtos_WhenLevelFound() { var LevelDTO = new LevelDTO() { Id = 1, Name = "Teste" }; var expectedLevelReturn = new Level() { Id = 1, Name = "Teste" }; _serviceMock.Setup(x => x.RegisterOrUpdate(It.IsAny <Level>())).Returns(expectedLevelReturn); var result = _controller.UpdateLevel(LevelDTO); _serviceMock.Verify(x => x.RegisterOrUpdate(It.IsAny <Level>()), Times.Once); var objectResult = Assert.IsType <OkObjectResult>(result.Result); Assert.Equal(200, objectResult.StatusCode); var dto = Assert.IsType <LevelDTO>(objectResult.Value); Assert.Equal(expectedLevelReturn.Name.ToLower(), dto.Name); }
public int UpdateLevelbyId(LevelDTO data) { Level lvl = LevelRequestFormatter.ConvertRespondentInfoFromDTO(data); var response = _unitOfWork.LevelRepository.Update(lvl); _unitOfWork.Save(); return(response); }
public ActionResult <LevelDTO> PostLevel([FromBody] LevelDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_mapper.Map <LevelDTO>(_service.RegisterOrUpdateLevel(_mapper.Map <Level>(value))))); }
public LevelDTO InsertLevel(LevelDTO data) { Level level = LevelRequestFormatter.ConvertRespondentInfoFromDTO(data); _level.LevelId = level.LevelId; _level.LevelName = level.LevelName; _level.LevelOrder = level.LevelOrder; return(LevelRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.LevelRepository.Create(level))); }
public void Validation_ModelState_False() { var dto = new LevelDTO(); var context = new ValidationContext(dto, null, null); var results = new List <ValidationResult>(); var isModelStateValid = Validator.TryValidateObject(dto, context, results, true); Assert.False(isModelStateValid); }
public void Setup() { quizService = A.Fake <IQuizService>(); testTopic = new TopicDTO(Guid.NewGuid(), "TestTopicName"); testLevel = new LevelDTO(Guid.NewGuid(), "TestLevelName"); A.CallTo(() => quizService.GetTopics()).Returns(new[] { testTopic }); A.CallTo(() => quizService.GetLevels(testTopic.Id)).Returns(new[] { testLevel }); userRepository = A.Fake <IUserRepository>(); stateMachine = new TelegramStateMachine(quizService, userRepository); }
public ActionResult PersonalInfo() { UserDTO model = UserServer.GetModel(9); LevelDTO lvel = lvelname.GetLevelName(model.LevelID); ViewBag.BankModelList = brank.GetAllList(); if (lvel != null) { model.LevelName = lvel.LevelName; } return(View(model)); }
public ActionResult LevelEdit(LevelDTO data) { if (!ModelState.IsValid) { return(View(data)); } int reLevel = _levelService.UpdateLevelbyId(data); ViewBag.Succeess = "Level has been updated successfully"; ModelState.Clear(); return(View(data)); }
public LevelDTO GetLevelById(int levelId) { var levellist = _unitOfWork.LevelRepository.All(); LevelDTO levelDetail = (from lvl in levellist select new LevelDTO { LevelId = lvl.LevelId, LevelName = lvl.LevelName, LevelOrder = lvl.LevelOrder }).Where(x => x.LevelId == levelId).FirstOrDefault(); return(levelDetail); }
public ActionResult <LevelDTO> CreateLevel(LevelDTO level) { if (String.IsNullOrWhiteSpace(level.Name)) { return(StatusCode(400)); } var entity = _mapper.Map <Level>(level); _levelRepository.Save(entity); var levelDto = _mapper.Map <LevelDTO>(_levelRepository.GetById(entity.Id)); return(Ok(_mapper.Map <LevelDTO>(levelDto))); }
public static Level ConvertRespondentInfoFromDTO(LevelDTO levelDTO) { Mapper.CreateMap <LevelDTO, Level>().ConvertUsing( m => { return(new Level { LevelId = m.LevelId, LevelName = m.LevelName, LevelOrder = m.LevelOrder }); }); return(Mapper.Map <LevelDTO, Level>(levelDTO)); }
public ActionResult <LevelDTO> UpdateLevel([FromBody] LevelDTO level) { if (ModelState.IsValid) { return(Ok (_mapper.Map <LevelDTO> (_service.RegisterOrUpdate (_mapper.Map <Level>(level))))); } else { return(BadRequest(ModelState)); } }
public async Task <int> AddLevel(LevelDTO level) { if (level == null) { throw new ArgumentNullException($"Level cannot be null"); } var newLevel = mapper.Map <Level>(level); await _ctx.Levels.AddAsync(newLevel); await _ctx.SaveChangesAsync(); return(newLevel.LevelId); }
public void SetActivity(LevelDTO value) { activity = value; gameCode = value.code; bundleUrl = value.pathAndroid; #if UNITY_ENGINE bundleUrl = value.pathAndroid; #elif UNITY_ANDROID bundleUrl = value.pathAndroid; #elif UNITY_IOS //bundleUrl = value.pathIOS; #endif }
GameObject CreateLevelButton(LevelDTO level) { var button = Instantiate(Button); button.transform.SetParent(gameObject.transform, false); var handler = button.gameObject.GetComponentInChildren <LevelSelectButtonHandler>(); Difficulty difficulty = level.Difficulty.ToDifficulty(); List <Operator> operators = level.Operators.Select(o => o.ToOperator()).ToList(); handler.SetUpButton(level.LevelNo, difficulty, level.Numbers, operators, level.NoQuestions, level.NoNumbers, level.NoBlanks); return(button); }
public async Task <LevelDTO> UpdateLevel(LevelDTO levelSrc) { var entityDest = await _ctx.Levels.FindAsync(levelSrc.LevelId); if (entityDest != null) { mapper.Map(levelSrc, entityDest); } else { return(null); } await _ctx.SaveChangesAsync(); return(await Task.FromResult(levelSrc)); }
public ActionResult Put([FromBody] LevelDTO level) { try { if (level == null) { return(NotFound()); } applicationServiceLevel.Update(level); return(Ok("Level Atualizado com sucesso!")); } catch (Exception) { throw; } }
public ActionResult Delete([FromBody] LevelDTO level) { try { if (level == null) { return(NotFound()); } applicationServiceLevel.Remove(level); return(Ok("Level Removido com sucesso!")); } catch (Exception ex) { throw ex; } }
public ActionResult Post([FromBody] LevelDTO level) { try { if (level == null) { return(NotFound()); } applicationServiceLevel.Add(level); return(Ok("Level Cadastrado com sucesso!")); } catch (Exception ex) { throw ex; } }
public ActionResult <Object> Post([FromBody] LevelDTO levelDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var levelFound = _repo.SelecionarPorNome(levelDTO.Name); if (levelFound != null) { return(BadRequest(new { errors = new ArrayList() { new { Name = "Name '" + levelDTO.Name + "' already exists!" } } })); } _repo.Incluir(_mapper.Map <Level>(levelDTO)); return(Ok(new { success = "Level '" + levelDTO.Name + "' created!" })); }
public ActionResult <Level> PostEnvironment([FromBody] LevelDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Level valor = _mapper.Map <Level>(value); var level = logs.RegisterOrUpdateLevel(valor); if (level != null) { return(Ok(level)); } else { return(NoContent()); } }
public ActionResult LevelCreate(LevelDTO data) { try { if (!ModelState.IsValid) { return(View(data)); } LevelDTO levelDTO = new LevelDTO(); levelDTO = _levelService.InsertLevel(data); ViewBag.success = String.Format("New Level Added"); ModelState.Clear(); return(View()); } catch (Exception Ex) { ViewBag.error = Ex.Message; return(View()); } }
public void SaveLevel_ShouldCallService_AndReturn200_WhenEverythingGoesRight() { var dto = new LevelDTO { Name = "Teste" }; var level = new Level { Id = 1, Name = "Teste" }; _serviceMock.Setup(x => x.RegisterOrUpdate(It.IsAny <Level>())).Returns(level); var result = _controller.SaveLevel(dto); var validation = _controller.ModelState.IsValid; _serviceMock.Verify(x => x.RegisterOrUpdate(It.IsAny <Level>()), Times.Once); var objectResult = Assert.IsType <OkObjectResult>(result.Result); Assert.Equal(200, objectResult.StatusCode); Assert.True(validation); }
public void SaveCurrentLevel(Level level) { GuardForInitialized(); var levelDto = new LevelDTO() { LevelNumber = level.Number, Description = level.Description }; var existingLevelsWithSameNumber = elevatorCollection.Find(Query.EQ("LevelNumber", level.Number)); if (existingLevelsWithSameNumber.Any()) { var existingLevel = existingLevelsWithSameNumber.First(); existingLevel.Description = level.Description; elevatorCollection.Save(existingLevel); } else { elevatorCollection.Save(levelDto); } }
/// <summary> /// Starts new session. /// </summary> /// <returns>The first question of the created session.</returns> /// <param name="pCategory">Category.</param> /// <param name="pLevel">Level.</param> /// <param name="pQuestionsQuantity">Questions quantity.</param> public ResponseDTO <SessionDTO> StartNewSession(CategoryDTO pCategory, LevelDTO pLevel, int pQuestionsQuantity) { if (LoggedUser == null) { return(ResponseDTO <SessionDTO> .Unauthorized("You must log in before starting a new session.")); } if (pCategory == null) { return(ResponseDTO <SessionDTO> .BadRequest("Select a category.")); } if (pLevel == null) { return(ResponseDTO <SessionDTO> .BadRequest("Select a level.")); } var response = _operativeService.NewSession(LoggedUser.Id, pCategory.Id, pLevel.Id, pQuestionsQuantity); if (response.Success) { CurrentSession = response.Data; CurrentSession.RemainingQuestions = CurrentSession.Questions.ToList(); } return(response); }
public ActionResult <Object> Delete([FromBody] LevelDTO levelDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var levelFound = _repo.SelecionarPorNome(levelDTO.Name); if (levelFound == null) { return(NotFound(new { message = "Name '" + levelDTO.Name + "' not found!" })); } if (_repoLogs.SelecionarTodos().Where(x => x.IdLevel == levelFound.Id).ToList().Count > 0) { return(BadRequest(new { errors = new ArrayList() { new { message = "You cannot delete this level, there are logs linked to it! Delete all linked logs before deleting this level." } } })); } _repo.Excluir(levelFound.Id); return(Ok(new { success = "Level '" + levelDTO.Name + "' deleted!" })); }
public IList <LevelDTO> GetGroupLocations() { SAPbobsCOM.Recordset lObjRecordset = null; IList <LevelDTO> LlstLevels = new List <LevelDTO>(); try { string lStrQuery = this.GetSQL("GetGroupLocation"); //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery); lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); lObjRecordset.DoQuery(lStrQuery); if (lObjRecordset.RecordCount > 0) { for (int i = 0; i < lObjRecordset.RecordCount; i++) { LevelDTO lObjLevelDTO = new LevelDTO(); lObjLevelDTO.IdLevel = lObjRecordset.Fields.Item("Code").Value.ToString(); lObjLevelDTO.Name = lObjRecordset.Fields.Item("Name").Value.ToString(); LlstLevels.Add(lObjLevelDTO); lObjRecordset.MoveNext(); } } } catch (Exception ex) { UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message)); LogService.WriteError("PurchasesDAO (GetItems): " + ex.Message); LogService.WriteError(ex); } finally { MemoryUtility.ReleaseComObject(lObjRecordset); } return(LlstLevels); }
public CheckTaskCommand(TopicDTO topicDto, LevelDTO levelDto, string answer) { this.topicDto = topicDto; this.levelDto = levelDto; this.answer = answer; }