Skip to content

Commit

Permalink
Se agrego y configuro para registro de alumnos
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel Arciniega committed Mar 3, 2017
1 parent 795ec23 commit dc52170
Show file tree
Hide file tree
Showing 14 changed files with 1,232 additions and 8 deletions.
127 changes: 127 additions & 0 deletions Renova/Renova/Controllers/alumnoesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Renova.Models;

namespace RenoEnergy.Controllers
{
public class alumnoesController : Controller
{
private RenoContext db = new RenoContext();

// GET: alumnoes
public ActionResult Index()
{
return View(db.alumnos.ToList());
}

// GET: alumnoes/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
alumno alumno = db.alumnos.Find(id);
if (alumno == null)
{
return HttpNotFound();
}
return View(alumno);
}

// GET: alumnoes/Create
public ActionResult Create()
{
return View();
}

// POST: alumnoes/Create
// Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "IDAlumno,nombre,apellidos,universidad,carrera,matricula,correo,fechareg")] alumno alumno)
{
if (ModelState.IsValid)
{
db.alumnos.Add(alumno);
db.SaveChanges();
return RedirectToAction("Index");
}

return View(alumno);
}

// GET: alumnoes/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
alumno alumno = db.alumnos.Find(id);
if (alumno == null)
{
return HttpNotFound();
}
return View(alumno);
}

// POST: alumnoes/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "IDAlumno,nombre,apellidos,universidad,carrera,matricula,correo,fechareg")] alumno alumno)
{
if (ModelState.IsValid)
{
db.Entry(alumno).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(alumno);
}

// GET: alumnoes/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
alumno alumno = db.alumnos.Find(id);
if (alumno == null)
{
return HttpNotFound();
}
return View(alumno);
}

// POST: alumnoes/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
alumno alumno = db.alumnos.Find(id);
db.alumnos.Remove(alumno);
db.SaveChanges();
return RedirectToAction("Index");
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}
132 changes: 132 additions & 0 deletions Renova/Renova/Controllers/asistenciasController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Renova.Models;

namespace RenoEnergy.Controllers
{
public class asistenciasController : Controller
{
private RenoContext db = new RenoContext();

// GET: asistencias
public ActionResult Index()
{
var asistencias = db.asistencias.Include(a => a.alumno);
return View(asistencias.ToList());
}

// GET: asistencias/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
asistencia asistencia = db.asistencias.Find(id);
if (asistencia == null)
{
return HttpNotFound();
}
return View(asistencia);
}

// GET: asistencias/Create
public ActionResult Create()
{
ViewBag.IDAlumno = new SelectList(db.alumnos, "IDAlumno", "nombre");
return View();
}

// POST: asistencias/Create
// Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "IDAsistencia,IDAlumno,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,estado")] asistencia asistencia)
{
if (ModelState.IsValid)
{
db.asistencias.Add(asistencia);
db.SaveChanges();
return RedirectToAction("Index");
}

ViewBag.IDAlumno = new SelectList(db.alumnos, "IDAlumno", "nombre", asistencia.IDAlumno);
return View(asistencia);
}

// GET: asistencias/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
asistencia asistencia = db.asistencias.Find(id);
if (asistencia == null)
{
return HttpNotFound();
}
ViewBag.IDAlumno = new SelectList(db.alumnos, "IDAlumno", "nombre", asistencia.IDAlumno);
return View(asistencia);
}

// POST: asistencias/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "IDAsistencia,IDAlumno,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,estado")] asistencia asistencia)
{
if (ModelState.IsValid)
{
db.Entry(asistencia).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.IDAlumno = new SelectList(db.alumnos, "IDAlumno", "nombre", asistencia.IDAlumno);
return View(asistencia);
}

// GET: asistencias/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
asistencia asistencia = db.asistencias.Find(id);
if (asistencia == null)
{
return HttpNotFound();
}
return View(asistencia);
}

// POST: asistencias/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
asistencia asistencia = db.asistencias.Find(id);
db.asistencias.Remove(asistencia);
db.SaveChanges();
return RedirectToAction("Index");
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}
16 changes: 14 additions & 2 deletions Renova/Renova/Renova.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\alumnoesController.cs" />
<Compile Include="Controllers\asistenciasController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
Expand Down Expand Up @@ -178,11 +180,21 @@
</Content>
<Content Include="Views\Web.config" />
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\alumnoes\Create.cshtml" />
<Content Include="Views\alumnoes\Delete.cshtml" />
<Content Include="Views\alumnoes\Details.cshtml" />
<Content Include="Views\alumnoes\Edit.cshtml" />
<Content Include="Views\alumnoes\Index.cshtml" />
<Content Include="Views\asistencias\Create.cshtml" />
<Content Include="Views\asistencias\Delete.cshtml" />
<Content Include="Views\asistencias\Details.cshtml" />
<Content Include="Views\asistencias\Edit.cshtml" />
<Content Include="Views\asistencias\Index.cshtml" />
<Content Include="Views\Home\About.cshtml" />
<Content Include="Views\Home\Contact.cshtml" />
<Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
Expand Down
11 changes: 5 additions & 6 deletions Renova/Renova/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Mi aplicación ASP.NET</title>
<title>Energias Renovables</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
Expand All @@ -17,13 +17,12 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Nombre de aplicación", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("Energias Renovables", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Inicio", "Index", "Home")</li>
<li>@Html.ActionLink("Acerca de", "About", "Home")</li>
<li>@Html.ActionLink("Contacto", "Contact", "Home")</li>
<li>@Html.ActionLink("Registro", "Create", "alumnoes")</li>
<li>@Html.ActionLink("Asistencia", "Index", "asistencias")</li>
</ul>
</div>
</div>
Expand All @@ -32,7 +31,7 @@
@RenderBody()
<hr />
<footer>
<p>&copy; @DateTime.Now.Year - Mi aplicación ASP.NET</p>
<p>&copy; @DateTime.Now.Year - Energias Renovables</p>
</footer>
</div>

Expand Down
Loading

0 comments on commit dc52170

Please sign in to comment.