public IActionResult Edit(PieceDto pieceDto) { _pieceService.Update(pieceDto); return(RedirectToAction("Index", "Piece")); }
public void Spawn(PieceDto p) { //siusti i kitu ekranus //string userId = User.Claims.First(c => c.Type == "UserID").Value; //_hubContext.Clients.AllExcept(ConnectedUser.Ids.GetValueOrDefault(userId)).SendAsync("Spawn", p.x, p.y, p.color, p.shape); //siusti i visu ekranus _hubContext.Clients.All.SendAsync("Spawn", p.x, p.y, p.color, p.shape); }
// POST api/pieces/validateMove public IHttpActionResult ValidateMove(PieceDto pieceDto) { var choosenPiece = Piece.RecognizePiece(pieceDto.Name); choosenPiece.Location = new Location(pieceDto.Location.X, pieceDto.Location.Y); Location nextLocation = new Location(pieceDto.NextLocation.X, pieceDto.NextLocation.Y); return(Ok(choosenPiece.ValidateMove(nextLocation))); }
private PieceDto getPieceDto(int id) { string url = "PieceData/findPiece/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { //Put data into player data transfer object PieceDto pieceDto = response.Content.ReadAsAsync <PieceDto>().Result; return(pieceDto); } return(null); }
public IHttpActionResult findPiece(int id) { //Find the data PieceDto piece = getPieceDto(id); //if not found, return 404 status code. if (piece == null) { return(NotFound()); } //pass along data as 200 status code OK response return(Ok(piece)); }
public void BizAction(PieceDto inputData) { var project = _dbAccess.GetPiece(inputData.Id); if (project == null) { AddError("Could not find the Piece.Someone entering illegal ids?"); return; } var status = project.UpdatePiece(inputData.Width, inputData.Height); CombineErrors(status); Message = $"Piece is update: {project.ToString()}."; }
// POST api/pieces/checkAvailableMoves public IHttpActionResult CheckAvailableMoves(PieceDto pieceDto) { var choosenPiece = Piece.RecognizePiece(pieceDto.Name); choosenPiece.Location = new Location(pieceDto.Location.X, pieceDto.Location.Y); var availableMoves = choosenPiece.CheckAvailableMoves(); var availableMovesDto = availableMoves.Select(move => new LocationDto() { X = move.X, Y = move.Y }).ToList(); return(Ok(availableMovesDto)); }
private PieceDto getPieceDto(Piece piece) { //put into a 'friendly object format' PieceDto pieceDto = new PieceDto { pieceId = piece.pieceId, pieceName = piece.pieceName, pieceDescription = piece.pieceDescription, height = piece.height, length = piece.length, width = piece.width, piecePrice = piece.piecePrice, formId = piece.formId }; return(pieceDto); }
private ShowPiece getShowPiece(int id) { ShowPiece piece = new ShowPiece(); PieceDto pieceDto = getPieceDto(id); // If not successful, return null. if (pieceDto == null) { return(null); } piece.piece = pieceDto; piece.form = getFormDto(pieceDto.formId); // Get only the techniques for this piece. piece.techniques = getTechniqueDtos(id); return(piece); }
public bool Update(PieceDto pieceDto) { Piece piece = new Piece() { Id = pieceDto.Id, }; try { _dbContext.Pieces.Attach(piece); _dbContext.SaveChanges(); _pieceCostService.Add(pieceDto.Price, pieceDto.PercentCustomer, pieceDto.PercentColleague, piece.Id); return(true); } catch (Exception ex) { return(false); } }
private UpdatePiece getUpdatePiece(int id) { UpdatePiece piece = new UpdatePiece(); PieceDto pieceDto = getPieceDto(id); // If not successful, return null. if (pieceDto == null) { return(null); } piece.piece = pieceDto; // Get a list of all the forms. piece.forms = getFormDtos(); // Get a list of the techniques used in this piece. piece.techniques = getTechniqueDtos(id); piece.notTechniques = getNotTechniqueDtos(id); return(piece); }
public bool Add(PieceDto pieceDto) { var dateNow = DateTime.Now; Piece piece = new Piece() { Id = pieceDto.Id, Name = pieceDto.Name, }; try { _dbContext.Pieces.Add(piece); _dbContext.SaveChanges(); _pieceCostService.Add(pieceDto.Price, pieceDto.PercentCustomer, pieceDto.PercentColleague, piece.Id); return(true); } catch (Exception ex) { return(false); } }
public ActionResult Create(Piece piece) { string url = "PieceData/addPiece"; Debug.WriteLine(jss.Serialize(piece)); HttpContent content = new StringContent(jss.Serialize(piece)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync(url, content).Result; if (response.IsSuccessStatusCode) { string jsonContent = response.Content.ReadAsStringAsync().Result; PieceDto pieceDto = jss.Deserialize <PieceDto>(jsonContent); return(RedirectToAction("Details", new { id = pieceDto.pieceId })); } else { return(RedirectToAction("Error")); } }
public Piece BizAction(PieceDto inputData) { if (inputData.Height <= 0) { AddError("Height of Piece is Invalied!!!"); } if (inputData.Width <= 0) { AddError("Width of Piece is Invalied!!!"); } var desStatus = Piece.CreatePiece(inputData.Width, inputData.Height); CombineErrors(desStatus); if (!HasErrors) { _dbAccess.Add(desStatus.Result); } return(HasErrors ? null : desStatus.Result); }
public IActionResult Create(PieceDto pieceDto) { _pieceService.Add(pieceDto); return(View()); }
public IActionResult PossibleMoves(PieceDto pic) { var resp = _moveRepo.PossibleMove(_gameRepo.GetGame(), pic.id); return(Ok(resp)); }
public IActionResult StartGame([FromBody] PieceDto piece) { Spawn(piece); return(Ok(piece)); }