public async Task EditarPeca(Peça peca) { if (ModelState.IsValid) { await _repository.AtualizarPeca(peca); } }
public async Task CriarNovaPeca(Peça peca) { if (ModelState.IsValid) { await _repository.AdicionarPeca(peca); } }
public Form1() { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; InitializeComponent(); atual = new Peça(); peça1 = new Peça(); peça2 = new Peça(); peça3 = new Peça(); peça4 = new Peça(); peça1.imagem = Properties.Resources._4p1_1; peça2.imagem = Properties.Resources._4p1_2; peça3.imagem = Properties.Resources._4p1_3; peça4.imagem = Properties.Resources._4p1_4; peças = new List <Peça>(); peça1.Name = "peça1"; peça2.Name = "peça2"; peça3.Name = "peça3"; peça4.Name = "peça4"; this.Controls.Add(peça1); this.Controls.Add(peça2); this.Controls.Add(peça3); this.Controls.Add(peça4); criaListaPecas(); foreach (Peça p in peças) { p.Size = new Size(p.imagem.Width, p.imagem.Height); } SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); associaEventosPecas(); canMove = false; }
public async Task AdicionarPeca(Peça peca) { var contexto = new DynamoDBContext(DynamoDBInitializer.client); peca.Id = Guid.NewGuid().ToString(); peca.Ativa = true; await contexto.SaveAsync <Peça>(peca); }
private void Form1_MouseDown(object sender, MouseEventArgs e) { if (sender.GetType().Equals(typeof(Peça)) && e.Button == MouseButtons.Left) { atual = sender as Peça; atual.BringToFront(); criaListaPecas(); if (atual.Down(e.Location)) { _Offset = new Point(e.X, e.Y); canMove = true; other = false; } else { Console.WriteLine(peças[1].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y))); Console.WriteLine(atual.Location); Point p = new Point(); if (peças[1].ClientRectangle.Contains(peças[1].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y))) && peças[1].Down(peças[1].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)))) { p = peças[1].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)); atual = peças[1]; atual.BringToFront(); criaListaPecas(); _Offset = p; canMove = true; other = true; } else if (peças[2].ClientRectangle.Contains(peças[2].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y))) && peças[2].Down(peças[2].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)))) { p = peças[2].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)); atual = peças[2]; atual.BringToFront(); criaListaPecas(); _Offset = p; canMove = true; other = true; } else if (peças[3].ClientRectangle.Contains(peças[3].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y))) && peças[3].Down(peças[3].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)))) { p = peças[3].PointToClient(new Point(e.X + atual.Location.X, e.Y + atual.Location.Y)); atual = peças[3]; atual.BringToFront(); criaListaPecas(); _Offset = p; canMove = true; other = true; } } } }
public async Task AtualizarPeca(Peça peca) { var contexto = new DynamoDBContext(DynamoDBInitializer.client); List <ScanCondition> condicao = new List <ScanCondition> (); condicao.Add(new ScanCondition("id", ScanOperator.Equal, peca.Id)); var todosDocumentos = await contexto.ScanAsync <Peça>(condicao).GetRemainingAsync(); var estadoEditado = todosDocumentos.FirstOrDefault(); if (estadoEditado != null) { estadoEditado = peca; await contexto.SaveAsync <Peça> (estadoEditado); } }