Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Index(int id)
- {
- var users = db.Educacions.Where(e => e.EmpleadoId == id).FirstOrDefault();
- return View(db.Educacions.Where(e => e.EmpleadoId == id)
- .OrderBy(e => e.EducacionId)
- .ThenBy(e => e.EducacionId)
- .ToPagedList(1, 5));
- }
- public async Task<ActionResult> Details(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Educacion educacion = await db.Educacions.FindAsync(id);
- if (educacion == null)
- {
- return HttpNotFound();
- }
- return View(educacion);
- }
- // GET: Educacions/Create
- public ActionResult Create(int id)
- {
- var users = db.Educacions.Where(e => e.EmpleadoId == id).FirstOrDefault();
- var educacion = new Educacion { EmpleadoId = id, };
- return View(educacion);
- //ViewBag.EmpleadoId = new SelectList(db.Empleadoes, "EmpleadoId", "EmpleadoId");
- //return View();
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public async Task<ActionResult> Create(Educacion educacion)
- {
- if (ModelState.IsValid)
- {
- db.Educacions.Add(educacion);
- await db.SaveChangesAsync();
- return RedirectToAction("Index");
- }
- ViewBag.EmpleadoId = new SelectList(db.Empleadoes, "EmpleadoId", "EmpleadoId", educacion.EmpleadoId);
- return View(educacion);
- }
- public async Task<ActionResult> Edit(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Educacion educacion = await db.Educacions.FindAsync(id);
- if (educacion == null)
- {
- return HttpNotFound();
- }
- ViewBag.EmpleadoId = new SelectList(db.Empleadoes, "EmpleadoId", "EmpleadoId", educacion.EmpleadoId);
- return View(educacion);
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public async Task<ActionResult> Edit(Educacion educacion)
- {
- if (ModelState.IsValid)
- {
- db.Entry(educacion).State = EntityState.Modified;
- await db.SaveChangesAsync();
- return RedirectToAction("Index");
- }
- ViewBag.EmpleadoId = new SelectList(db.Empleadoes, "EmpleadoId", "EmpleadoId", educacion.EmpleadoId);
- return View(educacion);
- }
- // GET: Educacions/Delete/5
- public async Task<ActionResult> Delete(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Educacion educacion = await db.Educacions.FindAsync(id);
- if (educacion == null)
- {
- return HttpNotFound();
- }
- return View(educacion);
- }
- [HttpPost, ActionName("Delete")]
- [ValidateAntiForgeryToken]
- public async Task<ActionResult> DeleteConfirmed(int id)
- {
- Educacion educacion = await db.Educacions.FindAsync(id);
- db.Educacions.Remove(educacion);
- await db.SaveChangesAsync();
- return RedirectToAction("Index");
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement