public static void updateEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var estadioEdit = kConnection.Raw("UPDATE[dbo].[estadios] SET[nombre] = '" + estadio.Nombre + "',[localidad] = '" + estadio.Localidad + "' WHERE id = " + estadio.Id); estadioEdit.Execute(); kConnection.Close(); }
public static void insertEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var insert = kConnection.Raw("INSERT INTO [dbo].[estadios] ([nombre], [localidad]) VALUES ('"+ estadio.Nombre +"','"+ estadio.Localidad +"')"); insert.Execute(); kConnection.Close(); }
public static object getEstadioById(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var estadios = kConnection.Raw("Select * from estadios where id = " + estadio.Id).ToList(); kConnection.Close(); return estadios; }
public static void deleteEstadio(Estadio estadio, IDataLink kConnection) { kConnection.Open(); var data = kConnection.Raw("DELETE FROM [dbo].[estadios] WHERE id = " + estadio.Id); data.Execute(); kConnection.Close(); }
public ActionResult Create(FormCollection formEstadio) { try { var objEstadio = new Estadio { Nombre = formEstadio["nombre"], Localidad = formEstadio["localidad"] }; Estadio.insertEstadio(objEstadio, kConnection); return RedirectToAction("Index"); } catch (Exception e) { return RedirectToAction("Index"); } }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here var objEstadio = new Estadio { Id = id }; Estadio.deleteEstadio(objEstadio, kConnection); return RedirectToAction("Index"); } catch (Exception e) { return RedirectToAction("Index"); } }
// GET: Estadios/Edit/5 public ActionResult Edit(int id) { var objEstadio = new Estadio { Id = id }; ViewBag.estadios = Estadio.getEstadioById(objEstadio, kConnection); ViewBag.id = id; return View(); }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here var objEstadio = new Estadio { Id = id, Nombre = collection["nombre"], Localidad = collection["localidad"] }; Estadio.updateEstadio(objEstadio, kConnection); return RedirectToAction("Index"); } catch { return RedirectToAction("Index"); } }