mirror of
https://github.com/guilhermewerner/gerencia-projetos
synced 2025-06-16 15:05:39 +00:00
Projeto Controller
This commit is contained in:
28
GerenciaProjetos/Controllers/BugsController.cs
Normal file
28
GerenciaProjetos/Controllers/BugsController.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GerenciaProjetos.Models;
|
||||
using GerenciaContext = GerenciaProjetos.Data.GerenciaContext;
|
||||
|
||||
namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
public class BugsController : Controller
|
||||
{
|
||||
private GerenciaContext ctx;
|
||||
|
||||
public BugsController(GerenciaContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(1);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
95
GerenciaProjetos/Controllers/DesenvolvedorController.cs
Normal file
95
GerenciaProjetos/Controllers/DesenvolvedorController.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GerenciaProjetos.Models;
|
||||
using GerenciaContext = GerenciaProjetos.Data.GerenciaContext;
|
||||
|
||||
namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
public class DesenvolvedorController : Controller
|
||||
{
|
||||
private GerenciaContext ctx;
|
||||
|
||||
public DesenvolvedorController(GerenciaContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(1);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.Desenvolvedores = ctx.Desenvolvedores;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult New()
|
||||
{
|
||||
return View("Form");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult New(Desenvolvedor dev)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Desenvolvedores.Add(dev);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("Form", dev);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Edit(int id)
|
||||
{
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(id);
|
||||
|
||||
if (dev != null)
|
||||
{
|
||||
return View("Form", dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Desenvolvedor dev)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Desenvolvedores.Update(dev);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("Form", dev);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Del(int id)
|
||||
{
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(id);
|
||||
|
||||
if (dev != null)
|
||||
{
|
||||
ctx.Desenvolvedores.Remove(dev);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
private GerenciaContext ctx;
|
||||
|
||||
|
||||
public HomeController(GerenciaContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
@ -24,7 +23,8 @@ namespace GerenciaProjetos.Controllers
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.Desenvolvedores = ctx.Desenvolvedores;
|
||||
|
||||
ViewBag.Projetos = ctx.Projetos;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -32,74 +32,7 @@ namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
/* DESENVOLVEDOR */
|
||||
|
||||
public IActionResult AddDev()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult AddDev(Desenvolvedor dev)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Desenvolvedores.Add(dev);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("AddDev", dev);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult EditDev(int id)
|
||||
{
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(id);
|
||||
|
||||
if (dev != null)
|
||||
{
|
||||
return View("AddDev", dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult EditDev(Desenvolvedor dev)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Desenvolvedores.Update(dev);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("AddDev", dev);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult DelDev(int id)
|
||||
{
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(id);
|
||||
|
||||
if (dev != null)
|
||||
{
|
||||
ctx.Desenvolvedores.Remove(dev);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
95
GerenciaProjetos/Controllers/ProjetosController.cs
Normal file
95
GerenciaProjetos/Controllers/ProjetosController.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GerenciaProjetos.Models;
|
||||
using GerenciaContext = GerenciaProjetos.Data.GerenciaContext;
|
||||
|
||||
namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
public class ProjetosController : Controller
|
||||
{
|
||||
private GerenciaContext ctx;
|
||||
|
||||
public ProjetosController(GerenciaContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(1);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.Projetos = ctx.Projetos;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult New()
|
||||
{
|
||||
return View("Form");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult New(Projeto proj)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Projetos.Add(proj);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("Form", proj);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Edit(int id)
|
||||
{
|
||||
Projeto proj = ctx.Projetos.Find(id);
|
||||
|
||||
if (proj != null)
|
||||
{
|
||||
return View("Form", proj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Projeto proj)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ctx.Projetos.Update(proj);
|
||||
ctx.SaveChanges();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("Form", proj);
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Del(int id)
|
||||
{
|
||||
Projeto proj = ctx.Projetos.Find(id);
|
||||
|
||||
if (proj != null)
|
||||
{
|
||||
ctx.Projetos.Remove(proj);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
}
|
28
GerenciaProjetos/Controllers/RequisitosController.cs
Normal file
28
GerenciaProjetos/Controllers/RequisitosController.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using GerenciaProjetos.Models;
|
||||
using GerenciaContext = GerenciaProjetos.Data.GerenciaContext;
|
||||
|
||||
namespace GerenciaProjetos.Controllers
|
||||
{
|
||||
public class RequisitosController : Controller
|
||||
{
|
||||
private GerenciaContext ctx;
|
||||
|
||||
public RequisitosController(GerenciaContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
|
||||
Desenvolvedor dev = ctx.Desenvolvedores.Find(1);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user