diff --git a/.vs/GerenciaProjetos/DesignTimeBuild/.dtbcache b/.vs/GerenciaProjetos/DesignTimeBuild/.dtbcache index 4a655ce..a78df82 100644 Binary files a/.vs/GerenciaProjetos/DesignTimeBuild/.dtbcache and b/.vs/GerenciaProjetos/DesignTimeBuild/.dtbcache differ diff --git a/.vs/GerenciaProjetos/v15/.suo b/.vs/GerenciaProjetos/v15/.suo index c1976c7..c7ff0e5 100644 Binary files a/.vs/GerenciaProjetos/v15/.suo and b/.vs/GerenciaProjetos/v15/.suo differ diff --git a/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide b/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide index 6894d4e..d768466 100644 Binary files a/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide and b/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide-wal b/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide-wal index 8e03991..0512f8e 100644 Binary files a/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide-wal and b/.vs/GerenciaProjetos/v15/Server/sqlite3/storage.ide-wal differ diff --git a/GerenciaProjetos/Controllers/HomeController.cs b/GerenciaProjetos/Controllers/HomeController.cs index fcced97..6fec36d 100644 --- a/GerenciaProjetos/Controllers/HomeController.cs +++ b/GerenciaProjetos/Controllers/HomeController.cs @@ -5,13 +5,26 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using GerenciaProjetos.Models; +using GerenciaContext = GerenciaProjetos.Data.GerenciaContext; namespace GerenciaProjetos.Controllers { public class HomeController : Controller { + private GerenciaContext ctx; + + + public HomeController(GerenciaContext ctx) + { + this.ctx = ctx; + + Desenvolvedor dev = ctx.Desenvolvedores.Find(1); + } + public IActionResult Index() { + ViewBag.Desenvolvedores = ctx.Desenvolvedores; + return View(); } @@ -20,6 +33,73 @@ 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() { diff --git a/GerenciaProjetos/Data/AppContext.cs b/GerenciaProjetos/Data/GerenciaContext.cs similarity index 74% rename from GerenciaProjetos/Data/AppContext.cs rename to GerenciaProjetos/Data/GerenciaContext.cs index 6c9e755..a0ccb7e 100644 --- a/GerenciaProjetos/Data/AppContext.cs +++ b/GerenciaProjetos/Data/GerenciaContext.cs @@ -7,7 +7,7 @@ using GerenciaProjetos.Models; namespace GerenciaProjetos.Data { - public class AppContext : DbContext + public class GerenciaContext : DbContext { public DbSet Bugs { get; set; } public DbSet Desenvolvedores { get; set; } @@ -17,7 +17,7 @@ namespace GerenciaProjetos.Data public DbSet DesenvolvedorProjeto { get; set; } public DbSet DesenvolvedorRequisito { get; set; } - public AppContext(DbContextOptions o) : base(o) + public GerenciaContext(DbContextOptions o) : base(o) { } @@ -25,11 +25,11 @@ namespace GerenciaProjetos.Data protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() - .HasKey(c => new { c.DesenvolvedorId, c.RequisitoId }); + .HasKey(b => new { b.DesenvolvedorId, b.RequisitoId }); modelBuilder.Entity() - .HasKey(c => new { c.DesenvolvedorId, c.ProjetoId }); + .HasKey(p => new { p.DesenvolvedorId, p.ProjetoId }); modelBuilder.Entity() - .HasKey(c => new { c.DesenvolvedorId, c.RequisitoId }); + .HasKey(r => new { r.DesenvolvedorId, r.RequisitoId }); } } } diff --git a/GerenciaProjetos/Migrations/20190921210546_1.Designer.cs b/GerenciaProjetos/Migrations/20190921210546_1.Designer.cs new file mode 100644 index 0000000..1d8d97a --- /dev/null +++ b/GerenciaProjetos/Migrations/20190921210546_1.Designer.cs @@ -0,0 +1,181 @@ +// +using System; +using GerenciaProjetos.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace GerenciaProjetos.Migrations +{ + [DbContext(typeof(GerenciaContext))] + [Migration("20190921210546_1")] + partial class _1 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("GerenciaProjetos.Models.Bug", b => + { + b.Property("DesenvolvedorId"); + + b.Property("RequisitoId"); + + b.HasKey("DesenvolvedorId", "RequisitoId"); + + b.HasIndex("RequisitoId"); + + b.ToTable("Bugs"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.Desenvolvedor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EAdmin"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100); + + b.Property("Nome") + .IsRequired() + .HasMaxLength(100); + + b.Property("Senha") + .IsRequired() + .HasMaxLength(45); + + b.HasKey("Id"); + + b.ToTable("Desenvolvedores"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.DesenvolvedorProjeto", b => + { + b.Property("DesenvolvedorId"); + + b.Property("ProjetoId"); + + b.HasKey("DesenvolvedorId", "ProjetoId"); + + b.HasIndex("ProjetoId"); + + b.ToTable("DesenvolvedorProjeto"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.DesenvolvedorRequisito", b => + { + b.Property("DesenvolvedorId"); + + b.Property("RequisitoId"); + + b.HasKey("DesenvolvedorId", "RequisitoId"); + + b.HasIndex("RequisitoId"); + + b.ToTable("DesenvolvedorRequisito"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.Projeto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DataEntrega"); + + b.Property("Nome") + .IsRequired() + .HasMaxLength(100); + + b.Property("Solicitante") + .IsRequired() + .HasMaxLength(45); + + b.HasKey("Id"); + + b.ToTable("Projetos"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.Requisito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DataCadastro"); + + b.Property("DataEntrega"); + + b.Property("Descricao") + .IsRequired() + .HasMaxLength(100); + + b.Property("EFuncional"); + + b.Property("Observacoes") + .HasMaxLength(100); + + b.Property("ProjetoId"); + + b.HasKey("Id"); + + b.HasIndex("ProjetoId"); + + b.ToTable("Requisitos"); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.Bug", b => + { + b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") + .WithMany() + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") + .WithMany() + .HasForeignKey("RequisitoId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.DesenvolvedorProjeto", b => + { + b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") + .WithMany() + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("GerenciaProjetos.Models.Projeto", "Projeto") + .WithMany() + .HasForeignKey("ProjetoId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.DesenvolvedorRequisito", b => + { + b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") + .WithMany() + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") + .WithMany() + .HasForeignKey("RequisitoId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("GerenciaProjetos.Models.Requisito", b => + { + b.HasOne("GerenciaProjetos.Models.Projeto", "Projeto") + .WithMany("Requisitos") + .HasForeignKey("ProjetoId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GerenciaProjetos/Migrations/20190921193724_1.cs b/GerenciaProjetos/Migrations/20190921210546_1.cs similarity index 78% rename from GerenciaProjetos/Migrations/20190921193724_1.cs rename to GerenciaProjetos/Migrations/20190921210546_1.cs index 8b6f966..7346691 100644 --- a/GerenciaProjetos/Migrations/20190921193724_1.cs +++ b/GerenciaProjetos/Migrations/20190921210546_1.cs @@ -44,18 +44,17 @@ namespace GerenciaProjetos.Migrations columns: table => new { DesenvolvedorId = table.Column(nullable: false), - ProjetoId = table.Column(nullable: false), - DesenvolvedorId1 = table.Column(nullable: true) + ProjetoId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_DesenvolvedorProjeto", x => new { x.DesenvolvedorId, x.ProjetoId }); table.ForeignKey( - name: "FK_DesenvolvedorProjeto_Desenvolvedores_DesenvolvedorId1", - column: x => x.DesenvolvedorId1, + name: "FK_DesenvolvedorProjeto_Desenvolvedores_DesenvolvedorId", + column: x => x.DesenvolvedorId, principalTable: "Desenvolvedores", principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DesenvolvedorProjeto_Projetos_ProjetoId", column: x => x.ProjetoId, @@ -93,28 +92,17 @@ namespace GerenciaProjetos.Migrations columns: table => new { DesenvolvedorId = table.Column(nullable: false), - RequisitoId = table.Column(nullable: false), - DesenvolvedorId1 = table.Column(nullable: true), - Prioridade = table.Column(nullable: true), - DataCadastro = table.Column(nullable: false), - CriadorId = table.Column(nullable: false), - FoiResolvido = table.Column(nullable: false) + RequisitoId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Bugs", x => new { x.DesenvolvedorId, x.RequisitoId }); table.ForeignKey( - name: "FK_Bugs_Desenvolvedores_CriadorId", - column: x => x.CriadorId, + name: "FK_Bugs_Desenvolvedores_DesenvolvedorId", + column: x => x.DesenvolvedorId, principalTable: "Desenvolvedores", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Bugs_Desenvolvedores_DesenvolvedorId1", - column: x => x.DesenvolvedorId1, - principalTable: "Desenvolvedores", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Bugs_Requisitos_RequisitoId", column: x => x.RequisitoId, @@ -128,19 +116,17 @@ namespace GerenciaProjetos.Migrations columns: table => new { DesenvolvedorId = table.Column(nullable: false), - RequisitoId = table.Column(nullable: false), - DesenvolvedorId1 = table.Column(nullable: true), - TempoGasto = table.Column(nullable: false) + RequisitoId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_DesenvolvedorRequisito", x => new { x.DesenvolvedorId, x.RequisitoId }); table.ForeignKey( - name: "FK_DesenvolvedorRequisito_Desenvolvedores_DesenvolvedorId1", - column: x => x.DesenvolvedorId1, + name: "FK_DesenvolvedorRequisito_Desenvolvedores_DesenvolvedorId", + column: x => x.DesenvolvedorId, principalTable: "Desenvolvedores", principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DesenvolvedorRequisito_Requisitos_RequisitoId", column: x => x.RequisitoId, @@ -149,36 +135,16 @@ namespace GerenciaProjetos.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateIndex( - name: "IX_Bugs_CriadorId", - table: "Bugs", - column: "CriadorId"); - - migrationBuilder.CreateIndex( - name: "IX_Bugs_DesenvolvedorId1", - table: "Bugs", - column: "DesenvolvedorId1"); - migrationBuilder.CreateIndex( name: "IX_Bugs_RequisitoId", table: "Bugs", column: "RequisitoId"); - migrationBuilder.CreateIndex( - name: "IX_DesenvolvedorProjeto_DesenvolvedorId1", - table: "DesenvolvedorProjeto", - column: "DesenvolvedorId1"); - migrationBuilder.CreateIndex( name: "IX_DesenvolvedorProjeto_ProjetoId", table: "DesenvolvedorProjeto", column: "ProjetoId"); - migrationBuilder.CreateIndex( - name: "IX_DesenvolvedorRequisito_DesenvolvedorId1", - table: "DesenvolvedorRequisito", - column: "DesenvolvedorId1"); - migrationBuilder.CreateIndex( name: "IX_DesenvolvedorRequisito_RequisitoId", table: "DesenvolvedorRequisito", diff --git a/GerenciaProjetos/Migrations/20190921193724_1.Designer.cs b/GerenciaProjetos/Migrations/20190921210818_2.Designer.cs similarity index 90% rename from GerenciaProjetos/Migrations/20190921193724_1.Designer.cs rename to GerenciaProjetos/Migrations/20190921210818_2.Designer.cs index 780e591..f345db4 100644 --- a/GerenciaProjetos/Migrations/20190921193724_1.Designer.cs +++ b/GerenciaProjetos/Migrations/20190921210818_2.Designer.cs @@ -5,13 +5,12 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using AppContext = GerenciaProjetos.Data.AppContext; namespace GerenciaProjetos.Migrations { - [DbContext(typeof(AppContext))] - [Migration("20190921193724_1")] - partial class _1 + [DbContext(typeof(GerenciaContext))] + [Migration("20190921210818_2")] + partial class _2 { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -30,8 +29,6 @@ namespace GerenciaProjetos.Migrations b.Property("DataCadastro"); - b.Property("DesenvolvedorId1"); - b.Property("FoiResolvido"); b.Property("Prioridade"); @@ -40,8 +37,6 @@ namespace GerenciaProjetos.Migrations b.HasIndex("CriadorId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("RequisitoId"); b.ToTable("Bugs"); @@ -77,12 +72,8 @@ namespace GerenciaProjetos.Migrations b.Property("ProjetoId"); - b.Property("DesenvolvedorId1"); - b.HasKey("DesenvolvedorId", "ProjetoId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("ProjetoId"); b.ToTable("DesenvolvedorProjeto"); @@ -94,14 +85,10 @@ namespace GerenciaProjetos.Migrations b.Property("RequisitoId"); - b.Property("DesenvolvedorId1"); - b.Property("TempoGasto"); b.HasKey("DesenvolvedorId", "RequisitoId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("RequisitoId"); b.ToTable("DesenvolvedorRequisito"); @@ -163,7 +150,8 @@ namespace GerenciaProjetos.Migrations b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") .WithMany() @@ -175,7 +163,8 @@ namespace GerenciaProjetos.Migrations { b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Projeto", "Projeto") .WithMany() @@ -187,7 +176,8 @@ namespace GerenciaProjetos.Migrations { b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") .WithMany() diff --git a/GerenciaProjetos/Migrations/20190921210818_2.cs b/GerenciaProjetos/Migrations/20190921210818_2.cs new file mode 100644 index 0000000..a491f2c --- /dev/null +++ b/GerenciaProjetos/Migrations/20190921210818_2.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace GerenciaProjetos.Migrations +{ + public partial class _2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TempoGasto", + table: "DesenvolvedorRequisito", + nullable: false, + defaultValue: new TimeSpan(0, 0, 0, 0, 0)); + + migrationBuilder.AddColumn( + name: "CriadorId", + table: "Bugs", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "DataCadastro", + table: "Bugs", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "FoiResolvido", + table: "Bugs", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "Prioridade", + table: "Bugs", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Bugs_CriadorId", + table: "Bugs", + column: "CriadorId"); + + migrationBuilder.AddForeignKey( + name: "FK_Bugs_Desenvolvedores_CriadorId", + table: "Bugs", + column: "CriadorId", + principalTable: "Desenvolvedores", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Bugs_Desenvolvedores_CriadorId", + table: "Bugs"); + + migrationBuilder.DropIndex( + name: "IX_Bugs_CriadorId", + table: "Bugs"); + + migrationBuilder.DropColumn( + name: "TempoGasto", + table: "DesenvolvedorRequisito"); + + migrationBuilder.DropColumn( + name: "CriadorId", + table: "Bugs"); + + migrationBuilder.DropColumn( + name: "DataCadastro", + table: "Bugs"); + + migrationBuilder.DropColumn( + name: "FoiResolvido", + table: "Bugs"); + + migrationBuilder.DropColumn( + name: "Prioridade", + table: "Bugs"); + } + } +} diff --git a/GerenciaProjetos/Migrations/AppContextModelSnapshot.cs b/GerenciaProjetos/Migrations/GerenciaContextModelSnapshot.cs similarity index 90% rename from GerenciaProjetos/Migrations/AppContextModelSnapshot.cs rename to GerenciaProjetos/Migrations/GerenciaContextModelSnapshot.cs index 4689256..5ac4733 100644 --- a/GerenciaProjetos/Migrations/AppContextModelSnapshot.cs +++ b/GerenciaProjetos/Migrations/GerenciaContextModelSnapshot.cs @@ -4,12 +4,11 @@ using GerenciaProjetos.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using AppContext = GerenciaProjetos.Data.AppContext; namespace GerenciaProjetos.Migrations { - [DbContext(typeof(AppContext))] - partial class AppContextModelSnapshot : ModelSnapshot + [DbContext(typeof(GerenciaContext))] + partial class GerenciaContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { @@ -28,8 +27,6 @@ namespace GerenciaProjetos.Migrations b.Property("DataCadastro"); - b.Property("DesenvolvedorId1"); - b.Property("FoiResolvido"); b.Property("Prioridade"); @@ -38,8 +35,6 @@ namespace GerenciaProjetos.Migrations b.HasIndex("CriadorId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("RequisitoId"); b.ToTable("Bugs"); @@ -75,12 +70,8 @@ namespace GerenciaProjetos.Migrations b.Property("ProjetoId"); - b.Property("DesenvolvedorId1"); - b.HasKey("DesenvolvedorId", "ProjetoId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("ProjetoId"); b.ToTable("DesenvolvedorProjeto"); @@ -92,14 +83,10 @@ namespace GerenciaProjetos.Migrations b.Property("RequisitoId"); - b.Property("DesenvolvedorId1"); - b.Property("TempoGasto"); b.HasKey("DesenvolvedorId", "RequisitoId"); - b.HasIndex("DesenvolvedorId1"); - b.HasIndex("RequisitoId"); b.ToTable("DesenvolvedorRequisito"); @@ -161,7 +148,8 @@ namespace GerenciaProjetos.Migrations b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") .WithMany() @@ -173,7 +161,8 @@ namespace GerenciaProjetos.Migrations { b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Projeto", "Projeto") .WithMany() @@ -185,7 +174,8 @@ namespace GerenciaProjetos.Migrations { b.HasOne("GerenciaProjetos.Models.Desenvolvedor", "Desenvolvedor") .WithMany() - .HasForeignKey("DesenvolvedorId1"); + .HasForeignKey("DesenvolvedorId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("GerenciaProjetos.Models.Requisito", "Requisito") .WithMany() diff --git a/GerenciaProjetos/Models/Bug.cs b/GerenciaProjetos/Models/Bug.cs index b6c1072..893c224 100644 --- a/GerenciaProjetos/Models/Bug.cs +++ b/GerenciaProjetos/Models/Bug.cs @@ -9,18 +9,16 @@ namespace GerenciaProjetos.Models { public class Bug { - [Key, Column(Order = 1)] public int DesenvolvedorId { get; set; } public Desenvolvedor Desenvolvedor { get; set; } - - [Key, Column(Order = 2)] + public int RequisitoId { get; set; } public Requisito Requisito { get; set; } - + public string Prioridade { get; set; } public DateTime DataCadastro { get; set; } - + public int CriadorId { get; set; } public Desenvolvedor Criador { get; set; } diff --git a/GerenciaProjetos/Models/DesenvolvedorProjeto.cs b/GerenciaProjetos/Models/DesenvolvedorProjeto.cs index 534b232..c5cb350 100644 --- a/GerenciaProjetos/Models/DesenvolvedorProjeto.cs +++ b/GerenciaProjetos/Models/DesenvolvedorProjeto.cs @@ -9,11 +9,9 @@ namespace GerenciaProjetos.Models { public class DesenvolvedorProjeto { - [Key, Column(Order = 1)] public int DesenvolvedorId { get; set; } public Desenvolvedor Desenvolvedor { get; set; } - - [Key, Column(Order = 2)] + public int ProjetoId { get; set; } public Projeto Projeto { get; set; } } diff --git a/GerenciaProjetos/Models/DesenvolvedorRequisito.cs b/GerenciaProjetos/Models/DesenvolvedorRequisito.cs index 65bc772..9a398b6 100644 --- a/GerenciaProjetos/Models/DesenvolvedorRequisito.cs +++ b/GerenciaProjetos/Models/DesenvolvedorRequisito.cs @@ -9,14 +9,12 @@ namespace GerenciaProjetos.Models { public class DesenvolvedorRequisito { - [Key, Column(Order = 1)] public int DesenvolvedorId { get; set; } public Desenvolvedor Desenvolvedor { get; set; } - - [Key, Column(Order = 2)] + public int RequisitoId { get; set; } public Requisito Requisito { get; set; } - + [DataType(DataType.Time)] public TimeSpan TempoGasto { get; set; } } diff --git a/GerenciaProjetos/Startup.cs b/GerenciaProjetos/Startup.cs index 61fe23d..2d6d6cd 100644 --- a/GerenciaProjetos/Startup.cs +++ b/GerenciaProjetos/Startup.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using AppContext = GerenciaProjetos.Data.AppContext; +using GerenciaContext = GerenciaProjetos.Data.GerenciaContext; namespace GerenciaProjetos { @@ -34,7 +34,7 @@ namespace GerenciaProjetos services.AddRouting(options => options.LowercaseUrls = true); - services.AddDbContext(options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection"))); + services.AddDbContext(options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection"))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } diff --git a/GerenciaProjetos/Views/Home/Index.cshtml b/GerenciaProjetos/Views/Home/Index.cshtml index 345a39d..06a67e0 100644 --- a/GerenciaProjetos/Views/Home/Index.cshtml +++ b/GerenciaProjetos/Views/Home/Index.cshtml @@ -7,8 +7,198 @@
-
- a +
+
+
+ Desenvolvedores +
+
+
+ + + +
+
+
+ + + + + + + + + + + + @foreach (Desenvolvedor d in ViewBag.Desenvolvedores) + { + + + + + + + + } + +
#NomeEmailAdminOpções
@d.Id@d.Nome@d.Email + @if (d.EAdmin == true) + { + Sim + } + else + { + Não + } + + + + + + + +
+
+
+ +
+
+
+
+
+ Projetos +
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
#NomeData de EntregaSolicitanteOpções
1GuilhermeAbrilKewin + + + + + + +
+
+
+ +
+
+
+
+
+ Requisitos +
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
#DescriçãoObservaçõesData de EntregaOpções
1GuilhermeAbrilKewin + + + + + + +
+
+
+ +
+
+
+
+
+ Bugs +
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
#PrioridadeData de CadastroData de EntregaResolvidoOpções
1GuilhermeAbrilKewinNão + + + + + + +
\ No newline at end of file diff --git a/GerenciaProjetos/Views/Shared/_Layout.cshtml b/GerenciaProjetos/Views/Shared/_Layout.cshtml index 046bd4b..e08643e 100644 --- a/GerenciaProjetos/Views/Shared/_Layout.cshtml +++ b/GerenciaProjetos/Views/Shared/_Layout.cshtml @@ -21,11 +21,11 @@
-