public async Task <IActionResult> Edit(long id, [Bind("Id,ResignDate,ResignStatus,Comment,Remark,CreatedDate,ApprovedDate,Status,Year,EmployeeInfoId")] Resign resign) { if (id != resign.Id) { return(NotFound()); } if (ModelState.IsValid) { try { //_context.Update(resign); //await _context.SaveChangesAsync(); await resignRepository.Update(resign); } catch (DbUpdateConcurrencyException) { if (!ResignExists(resign.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(resign)); }
public async Task <IActionResult> Create([Bind("Id,ResignDate,ResignStatus,Comment,Remark,CreatedDate,ApprovedDate,Status,Year,EmployeeInfoId")] ResignViewModel resign) { if (ModelState.IsValid) { Resign re = new Resign() { ResignDate = resign.ResignDate, ResignStatus = resign.ResignStatus, Comment = resign.Comment, Remark = resign.Remark, CreatedDate = resign.CreatedDate, ApprovedDate = resign.ApprovedDate, Status = resign.Status, Year = resign.Year, EmployeeInfoId = resign.EmployeeInfoId }; //_context.Add(resign); //await _context.SaveChangesAsync(); await resignRepository.Save(re); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.EmployeeInfoId); return(View(resign)); }
public async Task <IActionResult> Create([Bind("Id,ResignDate,Comment,CreatedDate,ApprovedDate,Status,Year,FromEmployeeInfoId,ToEmployeeInfoId")] ResignViewModel resign) { if (ModelState.IsValid) { Resign re = new Resign() { ResignDate = DateTime.Now, Comment = resign.Comment, CreatedDate = DateTime.Now, ApprovedDate = DateTime.Now, Status = "Pending", Year = DateTime.Now.Year.ToString(), FromEmployeeInfoId = resign.FromEmployeeInfoId, ToEmployeeInfoId = resign.ToEmployeeInfoId }; //_context.Add(resign); //await _context.SaveChangesAsync(); await resignRepository.Save(re); return(RedirectToAction(nameof(Index))); } ViewData["FromEmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.FromEmployeeInfoId); ViewData["ToEmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.ToEmployeeInfoId); return(View(resign)); }
public void the_game_being_ended_if_one_player_survives() { var command = new Resign(GameId, 4); Handle(command, Benelux()).Should().BeValid() .Value.Phase.Should().Be(GamePhase.Finished); }
public JsonResult Edit(Resign entity) { entity.CreateTime = DateTime.Now; entity.CreateUserId = this.CurrentUserId; this.iResignRepository.Save(entity); return(new JsonResult { Data = new Result(null) }); }
public void UpdateStatus(long ResignId, string status) { Resign resign = context.Resigns.Find(ResignId); resign.Status = status; resign.ApprovedDate = DateTime.Now; context.UpdateRange(resign); context.SaveChangesAsync(); if (status == LeaveStatus.Approve.ToString()) { UpdateEmployeeStatus(resign.FromEmployeeInfoId); } }
public void active_player_being_replaced_by_neutral() { var command = new Resign(GameId, 4); var buffer = BeneluxWithoutArmies() .Add(new ArmiesInitialized { Armies = new[] { Player.P1.Army(1), Player.P2.Army(80), Player.P3.Army(85), } }) .Add(new TurnStarted(Player.P1.Army(3))); var game = Handle(command, buffer).Should().BeValid().Value; game.Phase.Should().Be(GamePhase.Deploy); game.Countries.ById(Netherlands).Army.Should().Be(Player.Neutral.Army(1)); game.ActivePlayer.Should().Be(Player.P2); game.ActivePlayers.Should().BeEquivalentTo(new[] { Player.P2, Player.P3 }); }
public async Task <IActionResult> PutOpgeven([FromBody] Resign data) { var spelFromRepo = await repository.GetSpel(data.GameToken); if (spelFromRepo == null) { return(NotFound("SpelNotFound")); } Game game = spelFromRepo; var aanDeBeurt = game.Turn == Color.White ? game.Player1Token : game.Player2Token; if (data.PlayerToken != aanDeBeurt) { return(BadRequest()); } if (game.Resign()) { return(Ok()); } return(BadRequest()); }
public void Save(Resign entity) { if (string.IsNullOrWhiteSpace(entity.Id)) { entity.Id = Guid.NewGuid().ToString(); } var dbclass = this.context.Resign.Where(c => c.Id == entity.Id).FirstOrDefault(); if (dbclass == null) { dbclass = new Resign(); dbclass.Id = Guid.NewGuid().ToString(); this.context.Resign.Add(dbclass); } dbclass.CreateTime = entity.CreateTime == null ? dbclass.CreateTime : entity.CreateTime; dbclass.CreateUserId = entity.CreateUserId == null ? dbclass.CreateUserId : entity.CreateUserId; dbclass.Name = entity.Name == null ? dbclass.Name : entity.Name; dbclass.Description = entity.Description == null ? dbclass.Description : entity.Description; dbclass.Responsibility = entity.Responsibility == null ? dbclass.Responsibility : entity.Responsibility; this.context.SaveChanges(); }
public async Task Update(Resign ot) { context.Update(ot); await context.SaveChangesAsync(); }
public async Task Save(Resign ot) { context.Add(ot); await context.SaveChangesAsync(); }
public async Task Delete(Resign ot) { context.Remove(ot); await context.SaveChangesAsync(); }
public Result Handle(Resign command) => ExecuteAndSave(command, g => g.Resign());
private Response TryResign(Resign resign) { _gameState.Value = EGameState.Completed; return(Response.Ok); }