Sicherung

This commit is contained in:
Maier Stephan SI
2023-09-20 06:13:11 +02:00
parent baad999298
commit 939f9ca55c
17 changed files with 802 additions and 56 deletions

View File

@@ -0,0 +1,43 @@
using FSI.Prj.Mgt.Data;
using FSI.Prj.Mgt.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using X.PagedList;
namespace FSI.Prj.Mgt.Controllers
{
public class OrganizationController : Controller
{
private readonly ApplicationDbContext _context;
public OrganizationController(ApplicationDbContext context)
{
_context = context;
}
public IActionResult Index()
{
var organizations = _context.Organizations.ToList();
var org = organizations.Where(x => x.ParentId == 0 || x.ParentId == null).FirstOrDefault();
SetChildren(org, organizations);
return View(org);
}
private void SetChildren(Organization model, List<Organization> organizations)
{
var childs = organizations.Where(x => x.ParentId == model.Id).ToList();
foreach (var item in childs)
{
SetChildren(item, organizations);
model.Childs.Add(item);
}
}
}
}

View File

@@ -1,6 +1,7 @@
using FSI.Prj.Mgt.Data; using FSI.Prj.Mgt.Data;
using FSI.Prj.Mgt.Models; using FSI.Prj.Mgt.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using X.PagedList; using X.PagedList;
namespace FSI.Prj.Mgt.Controllers namespace FSI.Prj.Mgt.Controllers
@@ -16,18 +17,23 @@ namespace FSI.Prj.Mgt.Controllers
public async Task<IActionResult> Index(string searchString, int? page) public async Task<IActionResult> Index(string searchString, int? page)
{ {
var allProjects = from project in _context.Projects select project ;
IQueryable<Project> projects = _context.Projects.Include(x => x.Plant);
if (!string.IsNullOrEmpty(searchString)) if (!string.IsNullOrEmpty(searchString))
{ {
allProjects = allProjects.Where(x => x.No!.ToString().Contains(searchString) || x.Name!.Contains(searchString)|| x.Description!.Contains(searchString)); projects = projects.Where(x => x.No!.ToString().Contains(searchString) || x.Name!.Contains(searchString) || x.Description!.Contains(searchString));
} }
return View(await allProjects.ToPagedListAsync(page ?? 1, 10)); return View(await projects.ToPagedListAsync(page ?? 1, 10));
} }
public IActionResult CreateEdit(int id) public IActionResult CreateEdit(int id)
{ {
ViewBag.Plants = _context.Plants;
if (id == 0) if (id == 0)
{ {
return View(); return View();
@@ -54,49 +60,47 @@ namespace FSI.Prj.Mgt.Controllers
// Description = i.ToString(), // Description = i.ToString(),
// }; // };
if (project.Id == 0) if (project.Id == 0)
{
var highestPrjNo = 0;
int prjYear = 0;
int prjNo = 0;
if (_context.Projects.Count() > 0)
{ {
var highestPrjNo = 0; highestPrjNo = _context.Projects.Max(x => x.No);
int prjYear = 0; prjYear = highestPrjNo;
int prjNo = 0;
if (_context.Projects.Count() > 0) // Projekt Jahr freistellen
{ while (prjYear >= 100)
highestPrjNo = _context.Projects.Max(x => x.No); prjYear /= 10;
prjYear = highestPrjNo;
// Projekt Jahr freistellen // Laufende Nr. des Jahres freistellen
while (prjYear >= 100) prjNo = highestPrjNo >= 1000 ? highestPrjNo % 1000 : highestPrjNo;
prjYear /= 10; }
// Laufende Nr. des Jahres freistellen // Neue Projekt Nummer berechnen
prjNo = highestPrjNo >= 1000 ? highestPrjNo % 1000 : highestPrjNo; if (prjYear == int.Parse(DateTime.Now.ToString("yy")))
} {
project.No = prjYear * 1000 + prjNo + 1;
// Neue Projekt Nummer berechnen
if (prjYear == int.Parse(DateTime.Now.ToString("yy")))
{
project.No = prjYear * 1000 + prjNo + 1;
}
else
{
project.No = int.Parse(DateTime.Now.ToString("yy")) * 1000 + 1;
}
_context.Projects.Add(project);
} }
else else
{ {
_context.Projects.Update(project); project.No = int.Parse(DateTime.Now.ToString("yy")) * 1000 + 1;
} }
_context.Projects.Add(project);
}
else
{
_context.Projects.Update(project);
}
//} //}
_context.SaveChanges(); _context.SaveChanges();
return RedirectToAction("Index");
return RedirectToAction("Index");
} }
public IActionResult DeleteProject(int id) public IActionResult DeleteProject(int id)

View File

@@ -9,6 +9,10 @@ namespace FSI.Prj.Mgt.Data
public DbSet<Project> Projects { get; set; } public DbSet<Project> Projects { get; set; }
public DbSet<Plant> Plants { get; set; }
public DbSet<Organization> Organizations { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) : base(options)
{ {

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace FSI.Prj.Mgt.Data.Migrations namespace FSI.Prj.Mgt.Data.Migrations
{ {
[DbContext(typeof(ApplicationDbContext))] [DbContext(typeof(ApplicationDbContext))]
[Migration("20230915114704_addProjectDbSet")] [Migration("20230919061443_addedInitDbSet")]
partial class addProjectDbSet partial class addedInitDbSet
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -25,6 +25,35 @@ namespace FSI.Prj.Mgt.Data.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FSI.Prj.Mgt.Models.Plant", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Plants");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b => modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -44,11 +73,16 @@ namespace FSI.Prj.Mgt.Data.Migrations
b.Property<int>("No") b.Property<int>("No")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("PlantId");
b.ToTable("Projects"); b.ToTable("Projects");
}); });
@@ -254,6 +288,17 @@ namespace FSI.Prj.Mgt.Data.Migrations
b.ToTable("AspNetUserTokens", (string)null); b.ToTable("AspNetUserTokens", (string)null);
}); });
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{
b.HasOne("FSI.Prj.Mgt.Models.Plant", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{ {
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)

View File

@@ -0,0 +1,68 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FSI.Prj.Mgt.Data.Migrations
{
/// <inheritdoc />
public partial class addedInitDbSet : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Plants",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
SubPlantShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
SubPlantName = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Plants", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Projects",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
No = table.Column<int>(type: "int", nullable: false),
PlantId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Status = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Projects", x => x.Id);
table.ForeignKey(
name: "FK_Projects_Plants_PlantId",
column: x => x.PlantId,
principalTable: "Plants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Projects_PlantId",
table: "Projects",
column: "PlantId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Projects");
migrationBuilder.DropTable(
name: "Plants");
}
}
}

View File

@@ -0,0 +1,399 @@
// <auto-generated />
using System;
using FSI.Prj.Mgt.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FSI.Prj.Mgt.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20230919114347_addedOrganizationSet")]
partial class addedOrganizationSet
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ParentId")
.HasColumnType("int");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ParentId");
b.ToTable("Organizations");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Plant", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Plants");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("No")
.HasColumnType("int");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PlantId");
b.ToTable("Projects");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.HasOne("FSI.Prj.Mgt.Models.Organization", "Parent")
.WithMany("Childs")
.HasForeignKey("ParentId");
b.Navigation("Parent");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{
b.HasOne("FSI.Prj.Mgt.Models.Plant", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.Navigation("Childs");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -5,33 +5,43 @@
namespace FSI.Prj.Mgt.Data.Migrations namespace FSI.Prj.Mgt.Data.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class addProjectDbSet : Migration public partial class addedOrganizationSet : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Projects", name: "Organizations",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
No = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
ShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false), Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Status = table.Column<int>(type: "int", nullable: false) ParentId = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Projects", x => x.Id); table.PrimaryKey("PK_Organizations", x => x.Id);
table.ForeignKey(
name: "FK_Organizations_Organizations_ParentId",
column: x => x.ParentId,
principalTable: "Organizations",
principalColumn: "Id");
}); });
migrationBuilder.CreateIndex(
name: "IX_Organizations_ParentId",
table: "Organizations",
column: "ParentId");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Projects"); name: "Organizations");
} }
} }
} }

View File

@@ -22,6 +22,65 @@ namespace FSI.Prj.Mgt.Data.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ParentId")
.HasColumnType("int");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ParentId");
b.ToTable("Organizations");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Plant", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SubPlantShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Plants");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b => modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -41,11 +100,16 @@ namespace FSI.Prj.Mgt.Data.Migrations
b.Property<int>("No") b.Property<int>("No")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("PlantId");
b.ToTable("Projects"); b.ToTable("Projects");
}); });
@@ -251,6 +315,26 @@ namespace FSI.Prj.Mgt.Data.Migrations
b.ToTable("AspNetUserTokens", (string)null); b.ToTable("AspNetUserTokens", (string)null);
}); });
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.HasOne("FSI.Prj.Mgt.Models.Organization", "Parent")
.WithMany("Childs")
.HasForeignKey("ParentId");
b.Navigation("Parent");
});
modelBuilder.Entity("FSI.Prj.Mgt.Models.Project", b =>
{
b.HasOne("FSI.Prj.Mgt.Models.Plant", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{ {
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
@@ -301,6 +385,11 @@ namespace FSI.Prj.Mgt.Data.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("FSI.Prj.Mgt.Models.Organization", b =>
{
b.Navigation("Childs");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View File

@@ -8,6 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="jsTree" Version="3.1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.11" />

View File

@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace FSI.Prj.Mgt.Models
{
public class Organization
{
public int Id { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }
public string Description { get; set; }
public int? ParentId { get; set; }
[ForeignKey("ParentId")]
public virtual Organization Parent { get; set; }
public virtual ICollection<Organization> Childs { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.CompilerServices;
namespace FSI.Prj.Mgt.Models
{
public class Plant
{
public int Id { get; set; }
public string ShortName { get; set; }
public string Name { get; set; }
public string SubPlantShortName { get; set; }
public string SubPlantName { get; set; }
public string OutSh
{
get
{
return ShortName + " " + SubPlantShortName;
}
}
}
}

View File

@@ -6,23 +6,30 @@ namespace FSI.Prj.Mgt.Models
public class Project public class Project
{ {
public int Id { get; set; } public int Id { get; set; }
public int No{ get; set; } public int No{ get; set; }
[ForeignKey(nameof(Plant))]
public int PlantId { get; set; }
public virtual Plant Plant { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public ProjectStatus Status { get; set; } public ProjectStatus Status { get; set; }
[ForeignKey(nameof(StatusId))]
public virtual StatusNew StatusNew { get; set; }
} }
public enum ProjectStatus public enum ProjectStatus
{ {
[Display(Name = "in Bearbeitung")] [Display(Name = "in Bearbeitung")]
started, started,
[Display(Name = "beendet")] [Display(Name = "beendet")]
ended, ended,
[Display(Name = "zurückgestellt")] [Display(Name = "zurückgestellt")]
shelved, shelved,
} }
} }

View File

@@ -1,8 +0,0 @@
namespace FSI.Prj.Mgt.Models
{
public class StatusNew
{
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
@model FSI.Prj.Mgt.Models.Organization
<div id="divtree">
<ul id="tree">
<li>
<a href="#" class="usr">@Model.Name</a>
@Html.Partial("Childrens", Model)
</li>
</ul>
</div>
<script type="text/javascript">
$(funciton(){
$("#divtree").jstree();
});
</script>

View File

@@ -4,6 +4,7 @@
@model FSI.Prj.Mgt.Models.Project @model FSI.Prj.Mgt.Models.Project
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
@@ -25,6 +26,12 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col mb-3">
<select asp-for="PlantId" class="form-control" asp-items="@(new SelectList(@ViewBag.Plants, "Id", "OutSh"))"></select>
</div>
</div>
<div class="row"> <div class="row">
<div class="col mb-3"> <div class="col mb-3">
<input asp-for="Name" placeholder="Name" class="form-control" /> <input asp-for="Name" placeholder="Name" class="form-control" />

View File

@@ -19,7 +19,7 @@
<form asp-action="Index" method="get"> <form asp-action="Index" method="get">
<p> <p>
Suchen nach: <input type="text" name="SearchString" value=" "/> Suchen nach: <input type="text" name="SearchString" value=""/>
<input type="submit" value="suchen" /> <input type="submit" value="suchen" />
</p> </p>
</form> </form>
@@ -31,6 +31,7 @@
<tr> <tr>
<th hidden>Id</th> <th hidden>Id</th>
<th>Nr.</th> <th>Nr.</th>
<th>Anlage</th>
<th style="width:20%">Name</th> <th style="width:20%">Name</th>
<th>Bezeichnung</th> <th>Bezeichnung</th>
<th>Status</th> <th>Status</th>
@@ -49,6 +50,9 @@
<td> <td>
@project.No @project.No
</td> </td>
<td>
@project.Plant.Name @project.Plant.SubPlantShortName
</td>
<td> <td>
@project.Name @project.Name
</td> </td>

View File

@@ -1,3 +1,14 @@
# FSI.Prj.Mgt # FSI.Prj.Mgt
Projektverwaltungstool Projektverwaltungstool
## Befehle
Migration erstellen
- add-migration addedXXXDbSet
Änderungen auf DB ausrollen
- update-database
DB löschen/leeren
- update-database 0