private void btCadastrar_Click(object sender, EventArgs e) { if (dgvSalas.RowCount != 1) { using (var db = new dbEscala()) { try { for (int op = 0; op < dgvSalas.RowCount - 1; op++) { salas sa = new salas(); sa.DESCRICAO = Convert.ToString(dgvSalas.Rows[op].Cells[0].Value); db.Entry(sa).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } MessageBox.Show("Cadastro realizado com sucesso!!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalas.Rows.Clear(); TxtSala.Focus(); } catch (Exception err) { MessageBox.Show("Erro" + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Não há nada cadastrado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
// POST: api/salas public string Post([FromBody] salas sala) { using (desafioProgEntities bd = new desafioProgEntities()) { bd.salas.Add(sala); bd.SaveChanges(); return("Sala salva com sucesso"); } }
public async Task <ActionResult> Restore(int id) { salas salas = await db.salas.FindAsync(id); salas.deleted_at = null; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// PUT: api/salas/5 public string Put(int id, [FromBody] salas sala) { using (desafioProgEntities bd = new desafioProgEntities()) { salas salaAlterar = bd.salas.Find(id); salaAlterar.lotacao = sala.lotacao; bd.SaveChanges(); return("Alterado com sucesso"); } }
public async Task <ActionResult> DeleteConfirmed(int id) { salas salas = await db.salas.FindAsync(id); salas.deleted_at = DateTimeOffset.Now.DateTime; //db.salas.Remove(salas); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } salas salas = await db.salas.FindAsync(id); if (salas == null) { return(HttpNotFound()); } return(View(salas)); }
public async Task <ActionResult> Edit([Bind(Include = "id,local_id,nombre,created_at,updated_at,deleted_at")] salas salas) { if (ModelState.IsValid) { salas.updated_at = DateTimeOffset.Now.DateTime; db.Entry(salas).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.local_id = new SelectList(db.locales, "id", "nombre", salas.local_id); return(View(salas)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } salas salas = await db.salas.FindAsync(id); if (salas == null) { return(HttpNotFound()); } ViewBag.local_id = new SelectList(db.locales, "id", "nombre", salas.local_id); return(View(salas)); }