private async void BtnAddStage_Click(object sender, RoutedEventArgs e) { progressBar.Visibility = Visibility.Visible; var stage = new StageEntity { Name = txtName.Text, GPSCoordinate = txtLocation.Text, UploadDate = DateTime.Now }; if (!string.IsNullOrEmpty(stage.Name) || !string.IsNullOrEmpty(stage.GPSCoordinate)) { var response = await _httpClientService.PostAsync(stage, "Stages/add"); if (response.IsSuccessStatusCode) { MessageDialog messageDialog = new MessageDialog($"{stage.Name} has been registered"); await messageDialog.ShowAsync(); return; } else { txtError.Text = await response.Content.ReadAsStringAsync(); return; } } txtError.Text = "Invalid input"; progressBar.Visibility = Visibility.Collapsed; }
public void MapStage() { //Arrange var id = Guid.NewGuid(); var entity = new StageEntity() { Id = id, Events = new List <EventEntity>(), ImagePath = "ImagePath", Name = "Name", Description = "Description" }; var model = new StageDetailModel() { Id = id, Events = new List <EventDetailModel>(), ImagePath = "ImagePath", Name = "Name", Description = "Description" }; //Act var entityAdapted = model.Adapt <StageEntity>(); var modelAdapted = entity.Adapt <StageDetailModel>(); //Assert Assert.Equal(entity, entityAdapted, StageEntity.StageEntityComparer); Assert.Equal(model, modelAdapted, StageDetailModel.StageDetailModelComparer); }
public List <StageEntity> GetDataFromDB(ProjectAllocationFramework.Statues.ProgressChangedEventHandler OnProgress, StageSearchCondtion searchCondition = null) { List <StageEntity> entityList = new List <StageEntity>(); string sql = "select StageCode, StageName, Percent FROM [Stage] WHERE 1=1 and StageCode like @StageCode and StageName like @StageName ORDER BY StageCode"; DbCommand cmd = DatabaseUtil.GetCommand(db.GetSqlStringCommand(sql)); string stageCode = string.Empty; string stageName = string.Empty; if (searchCondition != null) { stageCode = searchCondition.StageCode.Trim(); stageName = searchCondition.StageName.Trim(); } db.AddInParameter(cmd, "StageCode", DbType.String, '%' + stageCode + '%'); db.AddInParameter(cmd, "StageName", DbType.String, '%' + stageName + '%'); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { StageEntity item = new StageEntity(); item.StageCode = ConvertUtil.ToString(reader["StageCode"]); item.StageName = ConvertUtil.ToString(reader["StageName"]); item.Percent = ConvertUtil.ToString(reader["Percent"]); item.Action = Constant.ACTION_UPDATE; item.ReadOnly = true; //throw new Exception(); entityList.Add(item); } } return(entityList); }
public InGameUser(StageEntity stageEntity, Status.Handle onGoldChanged, TimedConsumableCommandSet.Handle onChargedAttack) { status = new Status<User>(null, null); actionHandler = new ActionHandler(status); status.InitMinMaxVal(User.Gold, 0, stageEntity.maxGold, 0); status.InitMinMaxVal(User.Exp, 0, stageEntity.maxEXP, 0); status.InitMinMaxVal(User.Key, 0, stageEntity.maxKey, 0); AddAction(Action.E_Type.Money, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Gold, value); } ); AddAction(Action.E_Type.GetKey, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Key, value); } ); AddAction(Action.E_Type.Exp, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Exp, value); } ); status.RegisterOnChangeEvent(User.Gold, onGoldChanged); commandQueue = new TimedConsumableCommandSet(null, 100, false, null, onChargedAttack); }
public async Task UpdateStage_UpdatesAStageInDB_ReturnsObject() { // Arrange var connectionStringBuild = new SqliteConnectionStringBuilder { DataSource = ":memory:" }; var connection = new SqliteConnection(connectionStringBuild.ToString()); var options = new DbContextOptionsBuilder <StageBuilderDbContext>() .UseSqlite(connection) .Options; var entity = new StageEntity() { UserId = 1, GameId = 1, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now }; using (var context = new StageBuilderDbContext(options)) { context.Database.OpenConnection(); context.Database.EnsureCreated(); context.Stages.Add(entity); context.SaveChanges(); } using (var context = new StageBuilderDbContext(options)) { var updatedStage = new Stage() { UserId = 1, GameId = 1, }; var service = new StageService(context); // Act 1 var updatedEntity = await service.UpdateStageAsync(entity, updatedStage); // Assertion 1 var expectedName = "Updated stage 1"; var msg = $"Stage {updatedEntity.Name} has an updated"; using (new AssertionScope()) { updatedEntity.Name.Should().Be(expectedName, because: msg); } } }
public async Task <StageEntity> RemoveStageAsync(StageEntity Stage) { _context.Stages.Remove(Stage); if (await _context.SaveChangesAsync() > 0) { return(Stage); } else { throw new Exception($"Failed to remove {Stage.Name} from the database"); } }
public async Task AddStageAsync_AddsStage_WhenSuccessful() { // Arrange var connectionStringBuild = new SqliteConnectionStringBuilder { DataSource = ":memory:" }; var connection = new SqliteConnection(connectionStringBuild.ToString()); var options = new DbContextOptionsBuilder <StageBuilderDbContext>() .UseSqlite(connection) .Options; using (var context = new StageBuilderDbContext(options)) { await context.Database.OpenConnectionAsync(); await context.Database.EnsureCreatedAsync(); var stage = new StageEntity() { UserId = 1, GameId = 1, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now }; var service = new StageService(context); // Act 1 var entity = await service.AddStageAsync(stage); // Assertion 1 var expected = "Test stage 1"; var msg = $"Stage {entity.Name} was returned from add method"; entity.Name.Should().Be(expected, because: msg); } using (var context = new StageBuilderDbContext(options)) { var stages = context.Stages; // Act 2 - Check if item is is DB var id = 1; var entity = stages.First(p => p.StageId == id); // Assertion 2 var expected = "Test stage 1"; var msg = $"Stage {entity.Name} exists in database"; entity.Name.Should().Be(expected, because: msg); } }
public async Task <StageDTO> CreateStageAsync(CreateStageDTO createStageDTO) { var stage = new StageEntity { Name = createStageDTO.Name }; await _DBContext.Stages.AddAsync(stage); await _DBContext.SaveChangesAsync(); var stageDTO = _mapper.Map <StageDTO>(stage); return(stageDTO); }
public async Task <StageEntity> UpdateStageAsync(StageEntity entity, Stage model) { entity.Name = model.Name == null ? entity.Name : model.Name; entity.UserId = model.UserId == null ? entity.UserId : (int)model.UserId; entity.GameId = model.GameId == null ? entity.GameId : (int)model.GameId; entity.Published = model.Published == null ? entity.Published : (bool)model.Published; entity.TopBoundary = model.TopBoundary == null ? entity.TopBoundary : (int)model.TopBoundary; entity.BottomBoundary = model.BottomBoundary == null ? entity.BottomBoundary : (int)model.BottomBoundary; entity.LeftBoundary = model.LeftBoundary == null ? entity.LeftBoundary : (int)model.LeftBoundary; entity.RightBoundary = model.RightBoundary == null ? entity.RightBoundary : (int)model.RightBoundary; entity.LastUpdatedDate = DateTime.Now; await _context.SaveChangesAsync(); return(entity); }
public StageDTO CreateStage(int competitionId, int stageTypeId, IList <int> accounts) { StageEntity stage; try { stage = new StageEntity(competitionId, stageTypeId, new List <TaskEntity>(), accounts); this.competitionUnitOfWork.StageRepository.Create(stage); this.competitionUnitOfWork.SaveChanges(); } catch (Exception) { return(null); } return(ObjectMapper <StageEntity, StageDTO> .Map(stage)); }
public async Task <StageEntity> AddStageAsync(StageEntity entity) { var exists = await CheckForStageAsync(entity.Name); if (exists) { throw new InvalidOperationException($"{entity.Name} already exists"); } _context.Stages.Add(entity); if (await _context.SaveChangesAsync() > 0) { return(entity); } else { throw new Exception("Failed to save to the database"); } }
public async Task <StageEntity> UpdateStageBoundaries(StageEntity entity, int row, int col) { if (entity.TopBoundary < row) { entity.TopBoundary = row + 1; } if (entity.BottomBoundary > row) { entity.BottomBoundary = row; } if (entity.LeftBoundary > col) { entity.LeftBoundary = col; } if (entity.RightBoundary < col) { entity.RightBoundary = col + 1; } await _context.SaveChangesAsync(); return(entity); }
public List <StageEntity> GetData(params object[] paras) { this.EndEdit(); List <StageEntity> entityList = new List <StageEntity>(); int rowIdx = 1; foreach (DataGridViewRow item in this.Rows) { StageEntity entity = new StageEntity(); entity.Del = ConvertUtil.ToBoolean(item.Cells[this.delColumn.Name].Value); entity.StageCode = ConvertUtil.ToString(item.Cells[this.stageCodeColumn.Name].Value); entity.StageName = ConvertUtil.ToString(item.Cells[this.stageNameColumn.Name].Value); entity.Percent = ConvertUtil.ToString(item.Cells[this.percentColumn.Name].Value, "0.00"); entity.ReadOnly = item.Cells[this.stageCodeColumn.Name].ReadOnly; entity.Row = rowIdx; rowIdx++; if (!string.IsNullOrEmpty(entity.StageCode)) { entityList.Add(entity); } } return(entityList); }
public void MapEvent() { //Arrange var stageEntity = new StageEntity() { Id = Guid.NewGuid(), ImagePath = "ImagePath", Name = "Name", }; var stageModel = new StageListModel() { Id = stageEntity.Id, ImagePath = "ImagePath", Name = "Name", }; var bandEntity = new BandEntity { Id = Guid.NewGuid(), ImagePath = "ImagePath", Name = "Name", }; var bandModel = new BandListModel() { Id = bandEntity.Id, ImagePath = "ImagePath", Name = "Name", }; var id = Guid.NewGuid(); var entity = new EventEntity { Id = id, Start = new DateTime(2020, 11, 25, 12, 00, 00), End = new DateTime(2020, 11, 25, 14, 00, 00), BandId = bandEntity.Id, Band = bandEntity, StageId = stageEntity.Id, Stage = stageEntity }; var model = new EventDetailModel { Id = id, Start = new DateTime(2020, 11, 25, 12, 00, 00), End = new DateTime(2020, 11, 25, 14, 00, 00), BandId = bandModel.Id, Band = bandModel, StageId = stageModel.Id, Stage = stageModel }; //Act var entityAdapted = model.Adapt <EventEntity>(); var modelAdapted = entity.Adapt <EventDetailModel>(); //Assert Assert.Equal(entity, entityAdapted, EventEntity.EventEntityComparer); Assert.Equal(model, modelAdapted, EventDetailModel.EventDetailModelComparer); }
public BaseOperation() { _context = new StageEntity(); }
static void InitStage(int stageId, out StageEntity stageEntity, out GameModeEntity gameEntity) { stageEntity = TableLoader.GetTable<StageEntity>().Get(stageId); gameEntity = TableLoader.GetTable<GameModeEntity>().Get(stageEntity.GameModeType); }
public static void Run() { RenderWindow Window = WindowOptions.Window; Clock c = new Clock(); Time dTime = Time.FromSeconds(0); StageEntity Stage = new StageEntity(); PlayerEntity Player = new PlayerEntity(); List <IActor> ActorList = new List <IActor>(); ActorList.Add(Player); List <IStaticEntity> StaticEntityList = new List <IStaticEntity>(); StaticEntityList.Add(Stage); WindowOptions.AddGlobalEvents(Window); // Open while (Window.IsOpen) { c.Restart(); Window.DispatchEvents(); c.Restart(); // In Focus while (WindowOptions.InFocus && Window.IsOpen) { Window.DispatchEvents(); // Delay Exceeded if (c.ElapsedTime.AsMilliseconds() >= WindowOptions.Delay) { Window.DispatchEvents(); Window.Clear(Color.Cyan); Window.Draw(Stage.Shape); Window.Draw(Player.Shape); foreach (IActor actor in ActorList) { while (actor.Flags.Count > 0) { actor.Flags.Clear(); } } HandleInput(Player, dTime); foreach (IActor actor in ActorList) { Physics.Update(actor, dTime); } foreach (IActor actor in ActorList) { actor.Shape.Position += actor.Transformer.Velocity.Vector; } Window.Display(); dTime = c.Restart(); } } Window.Display(); } }
static Field CreateField(StageEntity stageEntity, Rect fieldArea, TimeClient timeClient, ItemDropManager itemDropManager, FSM fsm) { //PreloadTool.PreloadStage(stageEntity.StageID); Field field = new Field(fieldArea, timeClient); field.ChangeSceneary(stageEntity.Resource); field.AddObstacles(StageSpawn.SpawnWithPos(stageEntity.StageID), itemDropManager, fsm); return field; }
static InGameUser CreateUser(StageEntity stageEntity, UIInGameState ui, FSM fsm) { InGameUser user = new InGameUser(stageEntity, ui.ChangeGold, new ChargedAttackManager(fsm).OnChargedAttack); return user; }
public void FollowEntity(StageEntity entity) { m_entityImFollowing = entity; }
private void IncreaseStageCount() => StageEntity.IncreaseStageCount();
public void Create(StageEntity item) { _stages.Add(item); }
static void CreatePuzzle(StageEntity stageEntity, E_HeroType heroType, Rect puzzleArea, TimeClient timeClient, out PuzzleRecord puzzleRecord, out PuzzlePanel puzzlePanel) { puzzleRecord = new PuzzleRecord(); puzzlePanel = new PuzzlePanel(puzzleArea, heroType, stageEntity.GameModeType, puzzleRecord, timeClient); }
public void Update(StageEntity item) { _stages.RemoveAll(dto => dto.Id == item.Id); _stages.Add(item); }
private void SetAnswer(string answer) { StageEntity.Setup(answer); AnswerRenderer.Render(answer, !PlayerEntity.IsOwner(PhotonNetwork.LocalPlayer)); }