public async Task <ActionResult> Create([Bind(Include = "cod_ano,ano,activo")] anolectivo anolectivo) { if (ModelState.IsValid) { db.anolectivoes.Add(anolectivo); await db.SaveChangesAsync(); string s = "si"; if (anolectivo.activo == s) { SqlCommand cmdg1 = new SqlCommand(); DataTable dataTableg1 = new DataTable(); SqlDataAdapter sqlDAg1; con.Open(); cmdg1.CommandText = "UPDATE [dbo].[anolectivo] SET [activo] = 'no' WHERE id != " + anolectivo.cod_ano + ""; cmdg1.CommandType = CommandType.Text; cmdg1.Connection = con; sqlDAg1 = new SqlDataAdapter(cmdg1); sqlDAg1.Fill(dataTableg1); con.Close(); return(RedirectToAction("Index")); } } return(View(anolectivo)); }
public async Task <ActionResult> DeleteConfirmed(int id) { anolectivo anolectivo = await db.anolectivoes.FindAsync(id); db.anolectivoes.Remove(anolectivo); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "cod_ano,ano,activo")] anolectivo anolectivo) { if (ModelState.IsValid) { db.Entry(anolectivo).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(anolectivo)); }
// GET: anolectivoes/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } anolectivo anolectivo = await db.anolectivoes.FindAsync(id); if (anolectivo == null) { return(HttpNotFound()); } return(View(anolectivo)); }
// GET: anolectivoes/Edit/5 public async Task <ActionResult> Edit(int?id) { var activo = new[] { "si", "no" }; ViewBag.activo = new SelectList(activo); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } anolectivo anolectivo = await db.anolectivoes.FindAsync(id); if (anolectivo == null) { return(HttpNotFound()); } return(View(anolectivo)); }