#40 - Add models and database migration for Task Allocation

This commit is contained in:
Vikas Nale 2025-04-02 18:35:58 +05:30
parent 04d6c03b05
commit 1b16983092
18 changed files with 3108 additions and 274 deletions

View File

@ -43,7 +43,15 @@ namespace Marco.Pms.DataAccess.Data
public DbSet<WorkShift> WorkShifts { get; set; }
public DbSet<TaskAllocation> TaskAllocations { get; set; }
public DbSet<TaskComment> TaskComments { get; set; }
public DbSet<TaskMembers> TaskMembers { get; set; }
// public DbSet<Attendance> Attendances { get; set; }
public DbSet<Attendance> Attendes { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,543 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class TaskAllocationModels : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ActivityMasters_TaskAllocations_TaskAllocationId",
table: "ActivityMasters");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Buildings_BuildingId",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Employees_EmployeeId",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Projects_ProjectId",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_WorkAreas_WorkAreaId",
table: "TaskAllocations");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_BuildingId",
table: "TaskAllocations");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_EmployeeId",
table: "TaskAllocations");
migrationBuilder.DropIndex(
name: "IX_ActivityMasters_TaskAllocationId",
table: "ActivityMasters");
migrationBuilder.DropColumn(
name: "BuildingId",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "EmployeeId",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "TaskAllocationId",
table: "ActivityMasters");
migrationBuilder.RenameColumn(
name: "WorkAreaId",
table: "TaskAllocations",
newName: "WorkItemMappingId");
migrationBuilder.RenameColumn(
name: "ReAllocationDate",
table: "TaskAllocations",
newName: "ReportedDate");
migrationBuilder.RenameColumn(
name: "ProjectId",
table: "TaskAllocations",
newName: "WorkItemId");
migrationBuilder.RenameColumn(
name: "EmployeeRole",
table: "TaskAllocations",
newName: "AssignedBy");
migrationBuilder.RenameColumn(
name: "AllocationDate",
table: "TaskAllocations",
newName: "AssignmentDate");
migrationBuilder.RenameIndex(
name: "IX_TaskAllocations_WorkAreaId",
table: "TaskAllocations",
newName: "IX_TaskAllocations_WorkItemMappingId");
migrationBuilder.RenameIndex(
name: "IX_TaskAllocations_ProjectId",
table: "TaskAllocations",
newName: "IX_TaskAllocations_WorkItemId");
migrationBuilder.AlterColumn<double>(
name: "PlannedWork",
table: "WorkItems",
type: "double",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<double>(
name: "CompletedWork",
table: "WorkItems",
type: "double",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<long>(
name: "Id",
table: "TaskAllocations",
type: "bigint",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
migrationBuilder.AddColumn<double>(
name: "CompletedTask",
table: "TaskAllocations",
type: "double",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "TaskAllocations",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<double>(
name: "PlannedTask",
table: "TaskAllocations",
type: "double",
nullable: false,
defaultValue: 0.0);
migrationBuilder.CreateTable(
name: "TaskComments",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TaskAllocationId = table.Column<long>(type: "bigint", nullable: false),
CommentDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Comment = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CommentedBy = table.Column<int>(type: "int", nullable: false),
TenantId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskComments", x => x.Id);
table.ForeignKey(
name: "FK_TaskComments_Employees_CommentedBy",
column: x => x.CommentedBy,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TaskComments_TaskAllocations_TaskAllocationId",
column: x => x.TaskAllocationId,
principalTable: "TaskAllocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TaskComments_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "TaskMembers",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TaskAllocationId = table.Column<long>(type: "bigint", nullable: false),
EmployeeId = table.Column<int>(type: "int", nullable: false),
TenantId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskMembers", x => x.Id);
table.ForeignKey(
name: "FK_TaskMembers_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TaskMembers_TaskAllocations_TaskAllocationId",
column: x => x.TaskAllocationId,
principalTable: "TaskAllocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TaskMembers_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_AssignedBy",
table: "TaskAllocations",
column: "AssignedBy");
migrationBuilder.CreateIndex(
name: "IX_TaskComments_CommentedBy",
table: "TaskComments",
column: "CommentedBy");
migrationBuilder.CreateIndex(
name: "IX_TaskComments_TaskAllocationId",
table: "TaskComments",
column: "TaskAllocationId");
migrationBuilder.CreateIndex(
name: "IX_TaskComments_TenantId",
table: "TaskComments",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_TaskMembers_EmployeeId",
table: "TaskMembers",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_TaskMembers_TaskAllocationId",
table: "TaskMembers",
column: "TaskAllocationId");
migrationBuilder.CreateIndex(
name: "IX_TaskMembers_TenantId",
table: "TaskMembers",
column: "TenantId");
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Employees_AssignedBy",
table: "TaskAllocations",
column: "AssignedBy",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId",
table: "TaskAllocations",
column: "WorkItemMappingId",
principalTable: "WorkItemMapping",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_WorkItems_WorkItemId",
table: "TaskAllocations",
column: "WorkItemId",
principalTable: "WorkItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Employees_AssignedBy",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_WorkItems_WorkItemId",
table: "TaskAllocations");
migrationBuilder.DropTable(
name: "TaskComments");
migrationBuilder.DropTable(
name: "TaskMembers");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_AssignedBy",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "CompletedTask",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "Description",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "PlannedTask",
table: "TaskAllocations");
migrationBuilder.RenameColumn(
name: "WorkItemMappingId",
table: "TaskAllocations",
newName: "WorkAreaId");
migrationBuilder.RenameColumn(
name: "WorkItemId",
table: "TaskAllocations",
newName: "ProjectId");
migrationBuilder.RenameColumn(
name: "ReportedDate",
table: "TaskAllocations",
newName: "ReAllocationDate");
migrationBuilder.RenameColumn(
name: "AssignmentDate",
table: "TaskAllocations",
newName: "AllocationDate");
migrationBuilder.RenameColumn(
name: "AssignedBy",
table: "TaskAllocations",
newName: "EmployeeRole");
migrationBuilder.RenameIndex(
name: "IX_TaskAllocations_WorkItemMappingId",
table: "TaskAllocations",
newName: "IX_TaskAllocations_WorkAreaId");
migrationBuilder.RenameIndex(
name: "IX_TaskAllocations_WorkItemId",
table: "TaskAllocations",
newName: "IX_TaskAllocations_ProjectId");
migrationBuilder.AlterColumn<int>(
name: "PlannedWork",
table: "WorkItems",
type: "int",
nullable: false,
oldClrType: typeof(double),
oldType: "double");
migrationBuilder.AlterColumn<int>(
name: "CompletedWork",
table: "WorkItems",
type: "int",
nullable: false,
oldClrType: typeof(double),
oldType: "double");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "TaskAllocations",
type: "int",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
migrationBuilder.AddColumn<int>(
name: "BuildingId",
table: "TaskAllocations",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "EmployeeId",
table: "TaskAllocations",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "TaskAllocationId",
table: "ActivityMasters",
type: "int",
nullable: true);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 1,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 2,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 3,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 4,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 5,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 6,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 7,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 8,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 9,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 10,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 11,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 12,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 13,
column: "TaskAllocationId",
value: null);
migrationBuilder.UpdateData(
table: "ActivityMasters",
keyColumn: "Id",
keyValue: 14,
column: "TaskAllocationId",
value: null);
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_BuildingId",
table: "TaskAllocations",
column: "BuildingId");
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_EmployeeId",
table: "TaskAllocations",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_ActivityMasters_TaskAllocationId",
table: "ActivityMasters",
column: "TaskAllocationId");
migrationBuilder.AddForeignKey(
name: "FK_ActivityMasters_TaskAllocations_TaskAllocationId",
table: "ActivityMasters",
column: "TaskAllocationId",
principalTable: "TaskAllocations",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Buildings_BuildingId",
table: "TaskAllocations",
column: "BuildingId",
principalTable: "Buildings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Employees_EmployeeId",
table: "TaskAllocations",
column: "EmployeeId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Projects_ProjectId",
table: "TaskAllocations",
column: "ProjectId",
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_WorkAreas_WorkAreaId",
table: "TaskAllocations",
column: "WorkAreaId",
principalTable: "WorkAreas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -1,10 +1,7 @@
// <auto-generated />
using System;
using Marco.Pms.DataAccess.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
@ -20,118 +17,118 @@ namespace Marco.Pms.DataAccess.Migrations
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
//MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
// MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b =>
{
b.Property<int>("Id")
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<int>("AssignedBy")
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("AllocationDate")
b.Property<DateTime>("AssignmentDate")
.HasColumnType("datetime(6)");
b.Property<int>("BuildingId")
.HasColumnType("int");
b.Property<double>("CompletedTask")
.HasColumnType("double");
b.Property<int>("EmployeeId")
.HasColumnType("int");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("EmployeeRole")
.HasColumnType("int");
b.Property<double>("PlannedTask")
.HasColumnType("double");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.Property<DateTime>("ReAllocationDate")
b.Property<DateTime>("ReportedDate")
.HasColumnType("datetime(6)");
b.Property<int>("TenantId")
.HasColumnType("int");
b.Property<int>("WorkAreaId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("BuildingId");
b.HasIndex("EmployeeId");
b.HasIndex("ProjectId");
b.HasIndex("TenantId");
b.HasIndex("WorkAreaId");
b.ToTable("TaskAllocations");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ActivityId")
.HasColumnType("int");
b.Property<int>("CompletedWork")
.HasColumnType("int");
b.Property<int>("PlannedWork")
.HasColumnType("int");
b.Property<DateTime>("TaskDate")
.HasColumnType("datetime(6)");
b.Property<int>("TenantId")
.HasColumnType("int");
b.Property<int>("WorkAreaId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId");
b.HasIndex("TenantId");
b.HasIndex("WorkAreaId");
b.ToTable("WorkItems");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TenantId")
.HasColumnType("int");
b.Property<int>("WorkAreaId")
.HasColumnType("int");
b.Property<int>("WorkItemId")
.HasColumnType("int");
b.Property<int>("WorkItemMappingId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssignedBy");
b.HasIndex("TenantId");
b.HasIndex("WorkAreaId");
b.HasIndex("WorkItemId");
b.ToTable("WorkItemMapping");
b.HasIndex("WorkItemMappingId");
b.ToTable("TaskAllocations");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskComment", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CommentDate")
.HasColumnType("datetime(6)");
b.Property<int>("CommentedBy")
.HasColumnType("int");
b.Property<long>("TaskAllocationId")
.HasColumnType("bigint");
b.Property<int>("TenantId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CommentedBy");
b.HasIndex("TaskAllocationId");
b.HasIndex("TenantId");
b.ToTable("TaskComments");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskMembers", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<int>("EmployeeId")
.HasColumnType("int");
b.Property<long>("TaskAllocationId")
.HasColumnType("bigint");
b.Property<int>("TenantId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.HasIndex("TaskAllocationId");
b.HasIndex("TenantId");
b.ToTable("TaskMembers");
});
modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b =>
@ -405,9 +402,6 @@ namespace Marco.Pms.DataAccess.Migrations
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("TaskAllocationId")
.HasColumnType("int");
b.Property<int>("TenantId")
.HasColumnType("int");
@ -417,8 +411,6 @@ namespace Marco.Pms.DataAccess.Migrations
b.HasKey("Id");
b.HasIndex("TaskAllocationId");
b.HasIndex("TenantId");
b.ToTable("ActivityMasters");
@ -1333,6 +1325,71 @@ namespace Marco.Pms.DataAccess.Migrations
b.ToTable("WorkAreas");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.WorkItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ActivityId")
.HasColumnType("int");
b.Property<double>("CompletedWork")
.HasColumnType("double");
b.Property<double>("PlannedWork")
.HasColumnType("double");
b.Property<DateTime>("TaskDate")
.HasColumnType("datetime(6)");
b.Property<int>("TenantId")
.HasColumnType("int");
b.Property<int>("WorkAreaId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId");
b.HasIndex("TenantId");
b.HasIndex("WorkAreaId");
b.ToTable("WorkItems");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.WorkItemMapping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TenantId")
.HasColumnType("int");
b.Property<int>("WorkAreaId")
.HasColumnType("int");
b.Property<int>("WorkItemId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId");
b.HasIndex("WorkAreaId");
b.HasIndex("WorkItemId");
b.ToTable("WorkItemMapping");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
@ -1556,21 +1613,77 @@ namespace Marco.Pms.DataAccess.Migrations
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b =>
{
b.HasOne("Marco.Pms.Model.Projects.Building", "Building")
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
.WithMany()
.HasForeignKey("BuildingId")
.HasForeignKey("AssignedBy")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkItem", "WorkItem")
.WithMany()
.HasForeignKey("WorkItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkItemMapping", "WorkItemMapping")
.WithMany()
.HasForeignKey("WorkItemMappingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Tenant");
b.Navigation("WorkItem");
b.Navigation("WorkItemMapping");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskComment", b =>
{
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
.WithMany()
.HasForeignKey("CommentedBy")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", "TaskAllocation")
.WithMany()
.HasForeignKey("TaskAllocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("TaskAllocation");
b.Navigation("Tenant");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskMembers", b =>
{
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
.WithMany()
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.Project", "Project")
b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", "TaskAllocation")
.WithMany()
.HasForeignKey("ProjectId")
.HasForeignKey("TaskAllocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -1580,75 +1693,11 @@ namespace Marco.Pms.DataAccess.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea")
.WithMany()
.HasForeignKey("WorkAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Building");
b.Navigation("Employee");
b.Navigation("Project");
b.Navigation("TaskAllocation");
b.Navigation("Tenant");
b.Navigation("WorkArea");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.ActivityMaster", "ActivityMaster")
.WithMany()
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea")
.WithMany()
.HasForeignKey("WorkAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ActivityMaster");
b.Navigation("Tenant");
b.Navigation("WorkArea");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea")
.WithMany()
.HasForeignKey("WorkAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Activities.WorkItem", "WorkItem")
.WithMany()
.HasForeignKey("WorkItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tenant");
b.Navigation("WorkArea");
b.Navigation("WorkItem");
});
modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b =>
@ -1750,10 +1799,6 @@ namespace Marco.Pms.DataAccess.Migrations
modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b =>
{
b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", null)
.WithMany("AllotedTask")
.HasForeignKey("TaskAllocationId");
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
@ -1962,6 +2007,60 @@ namespace Marco.Pms.DataAccess.Migrations
b.Navigation("Tenant");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.WorkItem", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.ActivityMaster", "ActivityMaster")
.WithMany()
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea")
.WithMany()
.HasForeignKey("WorkAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ActivityMaster");
b.Navigation("Tenant");
b.Navigation("WorkArea");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.WorkItemMapping", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea")
.WithMany()
.HasForeignKey("WorkAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Projects.WorkItem", "WorkItem")
.WithMany()
.HasForeignKey("WorkItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tenant");
b.Navigation("WorkArea");
b.Navigation("WorkItem");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
@ -2013,11 +2112,6 @@ namespace Marco.Pms.DataAccess.Migrations
.IsRequired();
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b =>
{
b.Navigation("AllotedTask");
});
modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b =>
{
b.Navigation("FeaturePermissions");

View File

@ -11,42 +11,37 @@ namespace Marco.Pms.Model.Activities
{
public class TaskAllocation
{
public int Id { get; set; }
public int EmployeeId { get; set; }
[ForeignKey("EmployeeId")]
public long Id { get; set; }
public DateTime AssignmentDate { get; set; }
public double PlannedTask { get; set; }
public double CompletedTask { get; set; }
public DateTime ReportedDate { get; set; }
public string Description { get; set; }
public int WorkItemMappingId { get; set; }
[ForeignKey("WorkItemMappingId")]
[ValidateNever]
public WorkItemMapping WorkItemMapping { get; set; }
public int AssignedBy { get; set; }
[ForeignKey("AssignedBy")]
[ValidateNever]
public Employee Employee { get; set; }
public EMP_ROLES EmployeeRole { get; set; }
public int ProjectId { get; set; }
[ForeignKey("ProjectId")]
public int WorkItemId { get; set; }
[ForeignKey("WorkItemId")]
[ValidateNever]
public Project Project { get; set; }
public WorkItem WorkItem { get; set; }
public int BuildingId { get; set; }
[ForeignKey("BuildingId")]
[ValidateNever]
public Building Building { get; set; }
public DateTime AllocationDate { get; set; }
public DateTime ReAllocationDate { get; set; }
public int WorkAreaId { get; set; }
[ForeignKey("WorkAreaId")]
[ValidateNever]
public WorkArea WorkArea { get; set; }
public List<ActivityMaster> AllotedTask { get; set; }
[DisplayName("TenantId")]
public int TenantId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TenantId))]
public Tenant Tenant { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using Marco.Pms.Model.Employees;
using Marco.Pms.Model.Entitlements;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marco.Pms.Model.Activities
{
public class TaskComment
{
public long Id { get; set; }
public long TaskAllocationId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TaskAllocationId))]
public TaskAllocation TaskAllocation { get; set; }
public DateTime CommentDate { get; set; }
public string Comment { get; set; }
public int CommentedBy { get; set; }
[ForeignKey("CommentedBy")]
[ValidateNever]
public Employee Employee { get; set; }
public int TenantId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TenantId))]
public Tenant Tenant { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marco.Pms.Model.Activities
{
public class TaskImages
{
public long Id { get; set; }
public long TaskAllocationId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TaskAllocationId))]
public TaskAllocation TaskAllocation { get; set; }
public string ImagePath { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using Marco.Pms.Model.Employees;
using Marco.Pms.Model.Entitlements;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Marco.Pms.Model.Activities
{
public class TaskMembers
{
public long Id { get; set; }
public long TaskAllocationId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TaskAllocationId))]
public TaskAllocation TaskAllocation { get; set; }
public int EmployeeId { get; set; }
[ForeignKey("EmployeeId")]
[ValidateNever]
public Employee Employee { get; set; }
public int TenantId { get; set; }
[ValidateNever]
[ForeignKey(nameof(TenantId))]
public Tenant Tenant { get; set; }
}
}

View File

@ -0,0 +1,6 @@
namespace Marco.Pms.Model.Dtos.Activities
{
public class AssignTaskDto
{
}
}

View File

@ -1,4 +1,4 @@
using Marco.Pms.Model.Activities;
using Marco.Pms.Model.Projects;
namespace Marco.Pms.Model.Dtos.Project
{

View File

@ -0,0 +1,6 @@
namespace Marco.Pms.Model.Mapper
{
public class ActivitiesMapper
{
}
}

View File

@ -1,5 +1,4 @@
using Marco.Pms.Model.Activities;
using Marco.Pms.Model.Dtos.Project;
using Marco.Pms.Model.Dtos.Project;
using Marco.Pms.Model.Projects;
using System;
using System.Collections.Generic;

View File

@ -1,10 +1,9 @@
using Marco.Pms.Model.Entitlements;
using Marco.Pms.Model.Projects;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marco.Pms.Model.Activities
namespace Marco.Pms.Model.Projects
{
public class WorkItem
{
@ -21,8 +20,8 @@ namespace Marco.Pms.Model.Activities
[ValidateNever]
public ActivityMaster ActivityMaster { get; set; }
public int PlannedWork { get; set; }
public int CompletedWork { get; set; }
public double PlannedWork { get; set; }
public double CompletedWork { get; set; }
public DateTime TaskDate { get; set; }
[DisplayName("TenantId")]

View File

@ -1,10 +1,9 @@
using Marco.Pms.Model.Entitlements;
using Marco.Pms.Model.Projects;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marco.Pms.Model.Activities
namespace Marco.Pms.Model.Projects
{
public class WorkItemMapping
{

View File

@ -0,0 +1,6 @@
namespace Marco.Pms.Model.ViewModels.Activities
{
public class AssignedTaskVM
{
}
}

View File

@ -1,61 +0,0 @@
using Marco.Pms.DataAccess.Data;
using Marco.Pms.Model.Entitlements;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
namespace ModelServices.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class ActivityController : ControllerBase
{
private readonly ApplicationDbContext _context;
private ApplicationUser _applicationUser;
private readonly UserManager<IdentityUser> _userManager;
public ActivityController(UserManager<IdentityUser> userManager, ApplicationDbContext context)
{
_context = context;
_userManager = userManager;
}
//[HttpPost("checkin")]
//public async Task<IActionResult> CheckIn(int employeeId, string latitude, string longitude)
//{
// var now = DateTime.UtcNow;
// var date = now.Date;
// var attendanceLog = new AttendanceLog
// {
// EmployeeID = employeeId,
// //InTime = now,
// Latitude = latitude,
// Longitude = longitude
// };
// _context.AttendanceLogs.Add(attendanceLog);
// var attendance = await _context.Attendances
// .FirstOrDefaultAsync(a => a.EmployeeID == employeeId && a.Date == date);
// if (attendance == null)
// {
// attendance = new Attendance
// {
// EmployeeID = employeeId,
// Date = date,
// InTimeLog = attendanceLog
// };
// _context.Attendances.Add(attendance);
// }
// await _context.SaveChangesAsync();
// return Ok(new { Message = "Check-in recorded." });
//}
}
}

View File

@ -1,5 +1,4 @@
using Marco.Pms.DataAccess.Data;
using Marco.Pms.Model.Activities;
using Marco.Pms.Model.Dtos.Project;
using Marco.Pms.Model.Employees;
using Marco.Pms.Model.Entitlements;

View File

@ -23,11 +23,44 @@ namespace MarcoBMS.Services.Controllers
[HttpGet]
[Route("activities")]
public async Task<IActionResult> GetActivities()
public async Task<IActionResult> GetActivitiesMaster()
{
var activities = await _context.ActivityMasters.Where(c => c.TenantId == _userHelper.GetTenantId()).ToListAsync();
return Ok(activities);
}
[HttpPost("assign")]
public ActionResult AssignTask()
{
return Ok();
}
[HttpPost("report")]
public ActionResult ReportTaskProgress()
{
return Ok();
}
[HttpPost("comment")]
public ActionResult AddCommentForTask()
{
return Ok();
}
[HttpPost("list")]
public ActionResult GetTasksList()
{
return Ok();
}
[HttpPost("get/{taskId}")]
public ActionResult GetTask()
{
return Ok();
}
}
}