Added Apis for task allocations
This commit is contained in:
parent
352b4fb40e
commit
7ddb37852e
@ -39,7 +39,7 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
|
|
||||||
public DbSet<WorkArea> WorkAreas { get; set; }
|
public DbSet<WorkArea> WorkAreas { get; set; }
|
||||||
public DbSet<WorkItem> WorkItems { get; set; }
|
public DbSet<WorkItem> WorkItems { get; set; }
|
||||||
public DbSet<WorkItemMapping> WorkItemMapping { get; set; }
|
//public DbSet<WorkItemMapping> WorkItemMapping { get; set; }
|
||||||
|
|
||||||
public DbSet<WorkShift> WorkShifts { get; set; }
|
public DbSet<WorkShift> WorkShifts { get; set; }
|
||||||
|
|
||||||
|
2128
Marco.Pms.DataAccess/Migrations/20250403055023_Make_ReportDate_Nullable.Designer.cs
generated
Normal file
2128
Marco.Pms.DataAccess/Migrations/20250403055023_Make_ReportDate_Nullable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Make_ReportDate_Nullable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "ReportedDate",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "ReportedDate",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2059
Marco.Pms.DataAccess/Migrations/20250403133824_Removed_WorkItemMapping.Designer.cs
generated
Normal file
2059
Marco.Pms.DataAccess/Migrations/20250403133824_Removed_WorkItemMapping.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,131 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Removed_WorkItemMapping : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId",
|
||||||
|
table: "TaskAllocations");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "WorkItemMapping");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_TaskAllocations_WorkItemMappingId",
|
||||||
|
table: "TaskAllocations");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "WorkItemMappingId",
|
||||||
|
table: "TaskAllocations");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Description",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "TaskAllocations",
|
||||||
|
keyColumn: "Description",
|
||||||
|
keyValue: null,
|
||||||
|
column: "Description",
|
||||||
|
value: "");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Description",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldNullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "WorkItemMappingId",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "WorkItemMapping",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
TenantId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
WorkAreaId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
WorkItemId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_WorkItemMapping", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkItemMapping_Tenants_TenantId",
|
||||||
|
column: x => x.TenantId,
|
||||||
|
principalTable: "Tenants",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkItemMapping_WorkAreas_WorkAreaId",
|
||||||
|
column: x => x.WorkAreaId,
|
||||||
|
principalTable: "WorkAreas",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkItemMapping_WorkItems_WorkItemId",
|
||||||
|
column: x => x.WorkItemId,
|
||||||
|
principalTable: "WorkItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_TaskAllocations_WorkItemMappingId",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
column: "WorkItemMappingId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorkItemMapping_TenantId",
|
||||||
|
table: "WorkItemMapping",
|
||||||
|
column: "TenantId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorkItemMapping_WorkAreaId",
|
||||||
|
table: "WorkItemMapping",
|
||||||
|
column: "WorkAreaId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorkItemMapping_WorkItemId",
|
||||||
|
table: "WorkItemMapping",
|
||||||
|
column: "WorkItemId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId",
|
||||||
|
table: "TaskAllocations",
|
||||||
|
column: "WorkItemMappingId",
|
||||||
|
principalTable: "WorkItemMapping",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,10 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
using Marco.Pms.DataAccess.Data;
|
using Marco.Pms.DataAccess.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
@ -37,13 +40,12 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
.HasColumnType("double");
|
.HasColumnType("double");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<double>("PlannedTask")
|
b.Property<double>("PlannedTask")
|
||||||
.HasColumnType("double");
|
.HasColumnType("double");
|
||||||
|
|
||||||
b.Property<DateTime>("ReportedDate")
|
b.Property<DateTime?>("ReportedDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
b.Property<int>("TenantId")
|
b.Property<int>("TenantId")
|
||||||
@ -52,9 +54,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Property<int>("WorkItemId")
|
b.Property<int>("WorkItemId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("WorkItemMappingId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("AssignedBy");
|
b.HasIndex("AssignedBy");
|
||||||
@ -63,8 +62,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.HasIndex("WorkItemId");
|
b.HasIndex("WorkItemId");
|
||||||
|
|
||||||
b.HasIndex("WorkItemMappingId");
|
|
||||||
|
|
||||||
b.ToTable("TaskAllocations");
|
b.ToTable("TaskAllocations");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1362,34 +1359,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.ToTable("WorkItems");
|
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 =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
@ -1631,19 +1600,11 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Marco.Pms.Model.Projects.WorkItemMapping", "WorkItemMapping")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("WorkItemMappingId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Employee");
|
b.Navigation("Employee");
|
||||||
|
|
||||||
b.Navigation("Tenant");
|
b.Navigation("Tenant");
|
||||||
|
|
||||||
b.Navigation("WorkItem");
|
b.Navigation("WorkItem");
|
||||||
|
|
||||||
b.Navigation("WorkItemMapping");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskComment", b =>
|
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskComment", b =>
|
||||||
@ -2034,33 +1995,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Navigation("WorkArea");
|
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 =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
using Marco.Pms.Model.Employees;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.Projects;
|
using Marco.Pms.Model.Projects;
|
||||||
using Marco.Pms.Utility;
|
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Activities
|
namespace Marco.Pms.Model.Activities
|
||||||
@ -17,31 +15,29 @@ namespace Marco.Pms.Model.Activities
|
|||||||
public DateTime AssignmentDate { get; set; }
|
public DateTime AssignmentDate { get; set; }
|
||||||
public double PlannedTask { get; set; }
|
public double PlannedTask { get; set; }
|
||||||
public double CompletedTask { get; set; }
|
public double CompletedTask { get; set; }
|
||||||
|
public DateTime? ReportedDate { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
public DateTime ReportedDate { get; set; }
|
//public int? WorkItemMappingId { get; set; }
|
||||||
|
//[ForeignKey("WorkItemMappingId")]
|
||||||
|
//[ValidateNever]
|
||||||
|
//public WorkItemMapping? WorkItemMapping { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public int AssignedBy { get; set; } //Employee Id
|
||||||
|
|
||||||
public int WorkItemMappingId { get; set; }
|
|
||||||
[ForeignKey("WorkItemMappingId")]
|
|
||||||
[ValidateNever]
|
|
||||||
public WorkItemMapping WorkItemMapping { get; set; }
|
|
||||||
|
|
||||||
public int AssignedBy { get; set; }
|
|
||||||
[ForeignKey("AssignedBy")]
|
[ForeignKey("AssignedBy")]
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
public Employee Employee { get; set; }
|
public Employee? Employee { get; set; }
|
||||||
|
|
||||||
public int WorkItemId { get; set; }
|
public int WorkItemId { get; set; }
|
||||||
[ForeignKey("WorkItemId")]
|
[ForeignKey("WorkItemId")]
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
public WorkItem WorkItem { get; set; }
|
public WorkItem? WorkItem { get; set; }
|
||||||
|
|
||||||
public int TenantId { get; set; }
|
public int TenantId { get; set; }
|
||||||
|
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
[ForeignKey(nameof(TenantId))]
|
[ForeignKey(nameof(TenantId))]
|
||||||
public Tenant Tenant { get; set; }
|
public Tenant? Tenant { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,27 @@
|
|||||||
using Marco.Pms.Model.Employees;
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
|
using Marco.Pms.Model.Utilities;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Activities
|
namespace Marco.Pms.Model.Activities
|
||||||
{
|
{
|
||||||
public class TaskComment
|
public class TaskComment : TenantTest
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public long TaskAllocationId { get; set; }
|
public long TaskAllocationId { get; set; }
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
[ForeignKey(nameof(TaskAllocationId))]
|
[ForeignKey(nameof(TaskAllocationId))]
|
||||||
public TaskAllocation TaskAllocation { get; set; }
|
public TaskAllocation? TaskAllocation { get; set; }
|
||||||
|
|
||||||
public DateTime CommentDate { get; set; }
|
public DateTime CommentDate { get; set; }
|
||||||
public string Comment { get; set; }
|
public string Comment { get; set; }
|
||||||
public int CommentedBy { get; set; }
|
public int CommentedBy { get; set; }
|
||||||
[ForeignKey("CommentedBy")]
|
[ForeignKey("CommentedBy")]
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
public Employee Employee { get; set; }
|
public Employee? Employee { get; set; }
|
||||||
|
|
||||||
public int TenantId { get; set; }
|
|
||||||
|
|
||||||
[ValidateNever]
|
|
||||||
[ForeignKey(nameof(TenantId))]
|
|
||||||
public Tenant Tenant { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
using Marco.Pms.Model.Employees;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
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
|
namespace Marco.Pms.Model.Activities
|
||||||
{
|
{
|
||||||
|
@ -2,5 +2,11 @@
|
|||||||
{
|
{
|
||||||
public class AssignTaskDto
|
public class AssignTaskDto
|
||||||
{
|
{
|
||||||
|
public DateTime AssignmentDate { get; set; }
|
||||||
|
public double PlannedTask { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public List<int> TaskTeam { get; set; } //Employee Ids
|
||||||
|
public int WorkItemId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
Marco.Pms.Model/Dtos/Activities/CreateActivityMasterDto.cs
Normal file
10
Marco.Pms.Model/Dtos/Activities/CreateActivityMasterDto.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Dtos.Activities
|
||||||
|
{
|
||||||
|
public class CreateActivityMasterDto
|
||||||
|
{
|
||||||
|
public string ActivityName { get; set; }
|
||||||
|
public string UnitOfMeasurement { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
Marco.Pms.Model/Dtos/Activities/CreateCommentDto.cs
Normal file
11
Marco.Pms.Model/Dtos/Activities/CreateCommentDto.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Marco.Pms.Model.Dtos.Activities
|
||||||
|
{
|
||||||
|
public class CreateCommentDto
|
||||||
|
{
|
||||||
|
public long TaskAllocationId { get; set; }
|
||||||
|
|
||||||
|
public DateTime CommentDate { get; set; }
|
||||||
|
public string Comment { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
10
Marco.Pms.Model/Dtos/Activities/ReportTaskDto.cs
Normal file
10
Marco.Pms.Model/Dtos/Activities/ReportTaskDto.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Marco.Pms.Model.Dtos.Activities
|
||||||
|
{
|
||||||
|
public class ReportTaskDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public double CompletedTask { get; set; }
|
||||||
|
public DateTime ReportedDate { get; set; }
|
||||||
|
public string Comment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using System.ComponentModel;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
namespace Marco.Pms.Model.Entitlements
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,99 @@
|
|||||||
namespace Marco.Pms.Model.Mapper
|
using Marco.Pms.Model.Activities;
|
||||||
|
using Marco.Pms.Model.Dtos.Activities;
|
||||||
|
using Marco.Pms.Model.Entitlements;
|
||||||
|
using Marco.Pms.Model.ViewModels.Activities;
|
||||||
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Mapper
|
||||||
{
|
{
|
||||||
public class ActivitiesMapper
|
public static class ActivitiesMapper
|
||||||
{
|
{
|
||||||
|
public static TaskAllocation ToTaskAllocationFromAssignTaskDto(this AssignTaskDto assignTask, int EmployeeId,int tenantId)
|
||||||
|
{
|
||||||
|
return new TaskAllocation
|
||||||
|
{
|
||||||
|
AssignmentDate = assignTask.AssignmentDate,
|
||||||
|
PlannedTask = assignTask.PlannedTask,
|
||||||
|
CompletedTask = 0,
|
||||||
|
Description = assignTask.Description,
|
||||||
|
AssignedBy = EmployeeId,
|
||||||
|
WorkItemId = assignTask.WorkItemId,
|
||||||
|
TenantId = tenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static TaskComment ToCommentFromReportTaskDto(this ReportTaskDto reportTask, int tenantId, int EmployeeId)
|
||||||
|
{
|
||||||
|
return new TaskComment
|
||||||
|
{
|
||||||
|
TaskAllocationId = reportTask.Id,
|
||||||
|
CommentDate = reportTask.ReportedDate,
|
||||||
|
Comment = reportTask.Comment,
|
||||||
|
CommentedBy = EmployeeId,
|
||||||
|
TenantId = tenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static TaskComment ToCommentFromCommentDto(this CreateCommentDto createComment, int tenantId, int EmployeeId) {
|
||||||
|
return new TaskComment {
|
||||||
|
TaskAllocationId = createComment.TaskAllocationId,
|
||||||
|
CommentDate = createComment.CommentDate,
|
||||||
|
Comment = createComment.Comment,
|
||||||
|
CommentedBy = EmployeeId,
|
||||||
|
TenantId = tenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static TaskVM TaskAllocationToTaskVM(this TaskAllocation taskAllocation,string employeeName,string tenant )
|
||||||
|
{
|
||||||
|
return new TaskVM
|
||||||
|
{
|
||||||
|
Id = taskAllocation.Id,
|
||||||
|
AssignmentDate = taskAllocation.AssignmentDate,
|
||||||
|
PlannedTask = taskAllocation.PlannedTask,
|
||||||
|
CompletedTask = taskAllocation.CompletedTask,
|
||||||
|
ReportedDate = taskAllocation.ReportedDate,
|
||||||
|
Description = taskAllocation.Description,
|
||||||
|
AssignBy = employeeName,
|
||||||
|
Tenant = tenant,
|
||||||
|
WorkItem = taskAllocation.WorkItem
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static AssignedTaskVM ToAssignTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
|
||||||
|
{
|
||||||
|
return new AssignedTaskVM
|
||||||
|
{
|
||||||
|
Id = taskAllocation.Id,
|
||||||
|
AssignmentDate = taskAllocation.AssignmentDate,
|
||||||
|
PlannedTask = taskAllocation.PlannedTask,
|
||||||
|
CompletedTask = taskAllocation.CompletedTask,
|
||||||
|
ReportedDate= taskAllocation.ReportedDate,
|
||||||
|
Description = taskAllocation.Description,
|
||||||
|
AssignedBy = taskAllocation.Employee.ToEmployeeVMFromEmployee(),
|
||||||
|
WorkItemId = taskAllocation.WorkItemId,
|
||||||
|
TenantId = taskAllocation.TenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static ReportTaskVM ToReportTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
|
||||||
|
{
|
||||||
|
return new ReportTaskVM
|
||||||
|
{
|
||||||
|
Id = taskAllocation.Id,
|
||||||
|
AssignmentDate = taskAllocation.AssignmentDate,
|
||||||
|
PlannedTask = taskAllocation.PlannedTask,
|
||||||
|
CompletedTask = taskAllocation.CompletedTask,
|
||||||
|
ReportedDate = taskAllocation.ReportedDate,
|
||||||
|
Description = taskAllocation.Description,
|
||||||
|
AssignedBy = taskAllocation.AssignedBy,
|
||||||
|
WorkItemId = taskAllocation.WorkItemId,
|
||||||
|
TenantId = taskAllocation.TenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static ActivityMaster ToActivityMasterFromCreateActivityMasterDto(this CreateActivityMasterDto createActivity,int tenantId)
|
||||||
|
{
|
||||||
|
return new ActivityMaster
|
||||||
|
{
|
||||||
|
ActivityName = createActivity.ActivityName,
|
||||||
|
UnitOfMeasurement = createActivity.UnitOfMeasurement,
|
||||||
|
TenantId = tenantId
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using Marco.Pms.Model.Dtos.Project;
|
using Marco.Pms.Model.Dtos.Project;
|
||||||
using Marco.Pms.Model.Projects;
|
using Marco.Pms.Model.Projects;
|
||||||
using System;
|
using Marco.Pms.Model.ViewModels.Activities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Mapper
|
namespace Marco.Pms.Model.Mapper
|
||||||
{
|
{
|
||||||
@ -67,5 +63,12 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
//public static WorkItemVm ToWorkItemVMFromWorkItem(this WorkItem workItem)
|
||||||
|
//{
|
||||||
|
// return new WorkItemVm
|
||||||
|
// {
|
||||||
|
// Id
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace Marco.Pms.Model.Projects
|
namespace Marco.Pms.Model.Projects
|
||||||
{
|
{
|
||||||
public class WorkItemMapping
|
public class WorkItemMapping1
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int WorkAreaId { get; set; }
|
public int WorkAreaId { get; set; }
|
||||||
|
15
Marco.Pms.Model/Utilities/TenantTest.cs
Normal file
15
Marco.Pms.Model/Utilities/TenantTest.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Marco.Pms.Model.Entitlements;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Utilities
|
||||||
|
{
|
||||||
|
public class TenantTest
|
||||||
|
{
|
||||||
|
public int TenantId { get; set; }
|
||||||
|
|
||||||
|
[ValidateNever]
|
||||||
|
[ForeignKey(nameof(TenantId))]
|
||||||
|
public Tenant? Tenant { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,25 @@
|
|||||||
namespace Marco.Pms.Model.ViewModels.Activities
|
using Marco.Pms.Model.ViewModels.Employee;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.ViewModels.Activities
|
||||||
{
|
{
|
||||||
public class AssignedTaskVM
|
public class AssignedTaskVM
|
||||||
{
|
{
|
||||||
|
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 EmployeeVM? AssignedBy { get; set; }
|
||||||
|
|
||||||
|
public int WorkItemId { get; set; }
|
||||||
|
public int TenantId { get; set; }
|
||||||
|
public List<EmployeeVM> teamMembers { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
Marco.Pms.Model/ViewModels/Activities/ReportTaskVM.cs
Normal file
19
Marco.Pms.Model/ViewModels/Activities/ReportTaskVM.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Marco.Pms.Model.Activities;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.ViewModels.Activities
|
||||||
|
{
|
||||||
|
public class ReportTaskVM
|
||||||
|
{
|
||||||
|
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 AssignedBy { get; set; }
|
||||||
|
public int WorkItemId { get; set; }
|
||||||
|
public int TenantId { get; set; }
|
||||||
|
|
||||||
|
public List<TaskComment> Comments { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
Marco.Pms.Model/ViewModels/Activities/TaskVM.cs
Normal file
22
Marco.Pms.Model/ViewModels/Activities/TaskVM.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Marco.Pms.Model.Activities;
|
||||||
|
using Marco.Pms.Model.Projects;
|
||||||
|
using Marco.Pms.Model.ViewModels.Employee;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.ViewModels.Activities
|
||||||
|
{
|
||||||
|
public class TaskVM
|
||||||
|
{
|
||||||
|
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 string AssignBy { get; set; }
|
||||||
|
public WorkItem WorkItem { get; set; }
|
||||||
|
public string Tenant { get; set; }
|
||||||
|
|
||||||
|
public List<TaskComment> Comments { get; set; }
|
||||||
|
public List<EmployeeVM> TeamMembers { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
Marco.Pms.Model/ViewModels/Activities/TasksVM.cs
Normal file
12
Marco.Pms.Model/ViewModels/Activities/TasksVM.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace Marco.Pms.Model.ViewModels.Activities
|
||||||
|
{
|
||||||
|
public class TasksVM
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string ActivityName { get; set; }
|
||||||
|
public double TotalPlannedTask { get; set; }
|
||||||
|
public double PlannedTask { get; set; }
|
||||||
|
public double CompletedTask { get; set; }
|
||||||
|
public double TotalCopmletedTask { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
Marco.Pms.Model/ViewModels/Activities/WorkItemVM.cs
Normal file
11
Marco.Pms.Model/ViewModels/Activities/WorkItemVM.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Marco.Pms.Model.ViewModels.Activities
|
||||||
|
{
|
||||||
|
public class WorkItemVm
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ActivityName { get; set; }
|
||||||
|
public double PlannedWork { get; set; }
|
||||||
|
public double CompletedWork { get; set; }
|
||||||
|
public DateTime TaskDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace Marco.Pms.Model.ViewModels.Employee
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.ViewModels.Employee
|
|
||||||
{
|
{
|
||||||
public class EmployeeVM
|
public class EmployeeVM
|
||||||
{
|
{
|
||||||
|
17
Marco.Pms.Model/ViewModels/InfraVM.cs
Normal file
17
Marco.Pms.Model/ViewModels/InfraVM.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Marco.Pms.Model.Projects;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.ViewModels
|
||||||
|
{
|
||||||
|
public class InfraVM
|
||||||
|
{
|
||||||
|
public Building? building { get; set; }
|
||||||
|
public Floor? floor { get; set; }
|
||||||
|
|
||||||
|
public WorkArea workArea { get; set; }
|
||||||
|
}
|
||||||
|
}
|
37
Marco.Pms.Services/Controllers/MasterController.cs
Normal file
37
Marco.Pms.Services/Controllers/MasterController.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Model.Dtos.Activities;
|
||||||
|
using Marco.Pms.Model.Mapper;
|
||||||
|
using Marco.Pms.Model.Utilities;
|
||||||
|
using MarcoBMS.Services.Helpers;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Services.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class MasterController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly UserHelper _userHelper;
|
||||||
|
public MasterController(ApplicationDbContext context,UserHelper userHelper)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_userHelper = userHelper;
|
||||||
|
}
|
||||||
|
public async Task<IActionResult> CreateActivity([FromBody] CreateActivityMasterDto createActivity)
|
||||||
|
{
|
||||||
|
var tenantId = _userHelper.GetTenantId();
|
||||||
|
var employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
if(employee.TenantId != tenantId)
|
||||||
|
{
|
||||||
|
return Unauthorized(ApiResponse<object>.ErrorResponse("Current tenant did not match with user's tenant", "Current tenant did not match with user's tenant",401));
|
||||||
|
}
|
||||||
|
var activityMaster = createActivity.ToActivityMasterFromCreateActivityMasterDto(tenantId);
|
||||||
|
_context.ActivityMasters.Add(activityMaster);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(activityMaster, "Activity created successfully", 200));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -159,7 +159,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
List<WorkArea> workAreas = await _context.WorkAreas.Where(c => idList.Contains(c.FloorId)).ToListAsync();
|
List<WorkArea> workAreas = await _context.WorkAreas.Where(c => idList.Contains(c.FloorId)).ToListAsync();
|
||||||
|
|
||||||
idList = floors.Select(o => o.Id).ToList();
|
idList = workAreas.Select(o => o.Id).ToList();
|
||||||
List<WorkItem> workItems = await _context.WorkItems.Where(c => idList.Contains(c.WorkAreaId)).Include(c=>c.ActivityMaster).ToListAsync();
|
List<WorkItem> workItems = await _context.WorkItems.Where(c => idList.Contains(c.WorkAreaId)).Include(c=>c.ActivityMaster).ToListAsync();
|
||||||
// List <WorkItem> workItems = _unitOfWork.WorkItem.GetAll(c => idList.Contains(c.WorkAreaId), includeProperties: "ActivityMaster").ToList();
|
// List <WorkItem> workItems = _unitOfWork.WorkItem.GetAll(c => idList.Contains(c.WorkAreaId), includeProperties: "ActivityMaster").ToList();
|
||||||
|
|
||||||
@ -426,6 +426,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
[HttpPost("task")]
|
[HttpPost("task")]
|
||||||
public async Task<IActionResult> CreateProjectTask(List<WorkItemDot> workItemDot)
|
public async Task<IActionResult> CreateProjectTask(List<WorkItemDot> workItemDot)
|
||||||
{
|
{
|
||||||
|
List<WorkItem> workItems = new List<WorkItem> { };
|
||||||
if (workItemDot != null)
|
if (workItemDot != null)
|
||||||
{
|
{
|
||||||
foreach (var item in workItemDot)
|
foreach (var item in workItemDot)
|
||||||
@ -445,9 +446,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
_context.WorkItems.Add(workItem);
|
_context.WorkItems.Add(workItem);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
workItems.Add(workItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(null, "Data saved successfully.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(workItems, "Data saved successfully.", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Work Item Details are not valid.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Work Item Details are not valid.", 400));
|
||||||
@ -455,8 +457,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
[HttpPost("manage-infra")]
|
[HttpPost("manage-infra")]
|
||||||
public async Task<IActionResult> ManageProjectInfra(List<InfraDot> infraDots)
|
public async Task<IActionResult> ManageProjectInfra(List<InfraDot> infraDots)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
var responseData = new InfraVM{ };
|
||||||
if (infraDots != null)
|
if (infraDots != null)
|
||||||
{
|
{
|
||||||
foreach (var item in infraDots)
|
foreach (var item in infraDots)
|
||||||
@ -472,12 +474,15 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
//create
|
//create
|
||||||
_context.Buildings.Add(building);
|
_context.Buildings.Add(building);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.building = building;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//update
|
//update
|
||||||
_context.Buildings.Update(building);
|
_context.Buildings.Update(building);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.building = building;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.Floor != null)
|
if (item.Floor != null)
|
||||||
@ -490,12 +495,14 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
//create
|
//create
|
||||||
_context.Floor.Add(floor);
|
_context.Floor.Add(floor);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.floor = floor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//update
|
//update
|
||||||
_context.Floor.Update(floor);
|
_context.Floor.Update(floor);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.floor = floor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.WorkArea != null)
|
if (item.WorkArea != null)
|
||||||
@ -508,16 +515,18 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
//create
|
//create
|
||||||
_context.WorkAreas.Add(workArea);
|
_context.WorkAreas.Add(workArea);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.workArea = workArea;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//update
|
//update
|
||||||
_context.WorkAreas.Update(workArea);
|
_context.WorkAreas.Update(workArea);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
responseData.workArea = workArea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(null, "Data saved successfully.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(responseData, "Data saved successfully.", 200));
|
||||||
}
|
}
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Infra Details are not valid.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Infra Details are not valid.", 400));
|
||||||
|
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
using Marco.Pms.DataAccess.Data;
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Model.Activities;
|
||||||
|
using Marco.Pms.Model.Dtos.Activities;
|
||||||
|
using Marco.Pms.Model.Employees;
|
||||||
|
using Marco.Pms.Model.Mapper;
|
||||||
|
using Marco.Pms.Model.Projects;
|
||||||
|
using Marco.Pms.Model.Utilities;
|
||||||
|
using Marco.Pms.Model.ViewModels.Activities;
|
||||||
|
using Marco.Pms.Model.ViewModels.Employee;
|
||||||
using MarcoBMS.Services.Helpers;
|
using MarcoBMS.Services.Helpers;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -21,46 +29,199 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
_userHelper = userHelper;
|
_userHelper = userHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetTenantId()
|
||||||
|
{
|
||||||
|
return _userHelper.GetTenantId();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("activities")]
|
[Route("activities")]
|
||||||
public async Task<IActionResult> GetActivitiesMaster()
|
public async Task<IActionResult> GetActivitiesMaster()
|
||||||
{
|
{
|
||||||
var activities = await _context.ActivityMasters.Where(c => c.TenantId == _userHelper.GetTenantId()).ToListAsync();
|
var tenantId = GetTenantId();
|
||||||
|
var activities = await _context.ActivityMasters.Where(c => c.TenantId == tenantId).ToListAsync();
|
||||||
return Ok(activities);
|
return Ok(ApiResponse<object>.SuccessResponse(activities, "Success.", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpPost("assign")]
|
[HttpPost("assign")]
|
||||||
public ActionResult AssignTask()
|
public async Task<IActionResult> AssignTask([FromBody] AssignTaskDto assignTask)
|
||||||
{
|
{
|
||||||
return Ok();
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
var errors = ModelState.Values
|
||||||
|
.SelectMany(v => v.Errors)
|
||||||
|
.Select(e => e.ErrorMessage)
|
||||||
|
.ToList();
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||||
|
|
||||||
|
}
|
||||||
|
var tenantId = GetTenantId();
|
||||||
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
|
var taskAllocation = assignTask.ToTaskAllocationFromAssignTaskDto(Employee.Id,tenantId);
|
||||||
|
_context.TaskAllocations.Add(taskAllocation);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
var response = taskAllocation.ToAssignTaskVMFromTaskAllocation();
|
||||||
|
|
||||||
|
var teamMembers = new List<TaskMembers> { };
|
||||||
|
foreach (var teamMember in assignTask.TaskTeam) {
|
||||||
|
var result = new TaskMembers
|
||||||
|
{
|
||||||
|
TaskAllocationId = taskAllocation.Id,
|
||||||
|
EmployeeId = teamMember,
|
||||||
|
TenantId = tenantId,
|
||||||
|
};
|
||||||
|
teamMembers.Add(result);
|
||||||
|
}
|
||||||
|
_context.TaskMembers.AddRange(teamMembers);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var idList = teamMembers.Select(m => m.EmployeeId);
|
||||||
|
List<Employee> employees = await _context.Employees.Where(e=> idList.Contains(e.Id)).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var employee in employees) {
|
||||||
|
response.teamMembers.Add(employee.ToEmployeeVMFromEmployee());
|
||||||
|
}
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(response, "Task assignned successfully", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost("report")]
|
[HttpPost("report")]
|
||||||
public ActionResult ReportTaskProgress()
|
public async Task<IActionResult> ReportTaskProgress([FromBody]ReportTaskDto reportTask)
|
||||||
{
|
{
|
||||||
return Ok();
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
var errors = ModelState.Values
|
||||||
|
.SelectMany(v => v.Errors)
|
||||||
|
.Select(e => e.ErrorMessage)
|
||||||
|
.ToList();
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||||
|
|
||||||
|
}
|
||||||
|
var tenantId = GetTenantId();
|
||||||
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
|
var taskAllocation = await _context.TaskAllocations.Include(t => t.WorkItem).FirstOrDefaultAsync(t => t.Id == reportTask.Id);
|
||||||
|
if (taskAllocation == null) {
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("No such task has been allocated.", "No such task has been allocated.", 400));
|
||||||
|
}
|
||||||
|
|
||||||
|
taskAllocation.ReportedDate = reportTask.ReportedDate;
|
||||||
|
taskAllocation.CompletedTask = reportTask.CompletedTask;
|
||||||
|
taskAllocation.WorkItem.CompletedWork += reportTask.CompletedTask;
|
||||||
|
|
||||||
|
var comment = reportTask.ToCommentFromReportTaskDto(tenantId,Employee.Id);
|
||||||
|
|
||||||
|
_context.TaskComments.Add(comment);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
var response = taskAllocation.ToReportTaskVMFromTaskAllocation();
|
||||||
|
response.Comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(response, "Task reported successfully", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("comment")]
|
[HttpPost("comment")]
|
||||||
public ActionResult AddCommentForTask()
|
public async Task<IActionResult> AddCommentForTask([FromBody]CreateCommentDto createComment )
|
||||||
{
|
{
|
||||||
return Ok();
|
var tenantId = GetTenantId();
|
||||||
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
|
var comment = createComment.ToCommentFromCommentDto(tenantId, Employee.Id);
|
||||||
|
_context.TaskComments.Add(comment);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(comment, "Comment saved successfully", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("list")]
|
[HttpGet("list")]
|
||||||
public ActionResult GetTasksList()
|
public async Task<IActionResult> GetTasksList([FromQuery] int projectId, [FromQuery] string? dateFrom = null, [FromQuery] string? dateTo = null)
|
||||||
{
|
{
|
||||||
return Ok();
|
int tenantId = GetTenantId();
|
||||||
|
DateTime fromDate = new DateTime();
|
||||||
|
DateTime toDate = new DateTime();
|
||||||
|
|
||||||
|
if (dateFrom != null && DateTime.TryParse(dateFrom, out fromDate) == false)
|
||||||
|
{
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid starting date.", "Invalid starting date.", 400));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (dateTo != null && DateTime.TryParse(dateTo, out toDate) == false)
|
||||||
|
{
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid ending date.", "Invalid ending date.", 400));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (dateTo == null) toDate = DateTime.UtcNow;
|
||||||
|
if (dateFrom == null) fromDate = toDate.AddDays(-1);
|
||||||
|
|
||||||
|
//var taskAllocations = await _context.TaskAllocations.Where(t => t.WorkItem.WorkArea.Floor.Building.ProjectId == projectId && t.AssignmentDate >= fromDate && t.AssignmentDate <= toDate && t.TenantId == tenantId).Include(t => t.WorkItemId).ToListAsync();
|
||||||
|
List<Building> buildings = await _context.Buildings.Where(b => b.ProjectId == projectId && b.TenantId == tenantId).ToListAsync();
|
||||||
|
List<int> idList = buildings.Select(b => b.Id).ToList();
|
||||||
|
|
||||||
|
List<Floor> floors = await _context.Floor.Where(f => idList.Contains(f.BuildingId) && f.TenantId == tenantId).ToListAsync();
|
||||||
|
idList = floors.Select(f => f.Id).ToList();
|
||||||
|
|
||||||
|
List<WorkArea> workAreas = await _context.WorkAreas.Where(a => idList.Contains(a.FloorId) && a.TenantId == tenantId).ToListAsync();
|
||||||
|
idList = workAreas.Select(a => a.Id).ToList();
|
||||||
|
|
||||||
|
List<WorkItem> workItems = await _context.WorkItems.Where(i => idList.Contains(i.WorkAreaId) && i.TenantId == tenantId).Include(i => i.ActivityMaster).ToListAsync();
|
||||||
|
idList = workAreas.Select(i => i.Id).ToList();
|
||||||
|
|
||||||
|
List<TaskAllocation> taskAllocations = await _context.TaskAllocations.Where(t => idList.Contains(t.WorkItemId) && t.AssignmentDate >= fromDate && t.AssignmentDate <= toDate && t.TenantId == tenantId).Include(t => t.WorkItem).ToListAsync();
|
||||||
|
//var taskAllocations = await (from t in _context.TaskAllocations
|
||||||
|
// join w in _context.WorkItems on t.WorkItemId equals w.Id
|
||||||
|
// join a in _context.ActivityMasters on w.ActivityId equals a.Id
|
||||||
|
// where t.WorkItem.WorkArea.Floor.Building.ProjectId == projectId && t.AssignmentDate >= fromDate && t.AssignmentDate <= toDate && t.TenantId == tenantId
|
||||||
|
// select new {TaskAllocation = t, WorkItems = w, ActivityMasters = a }).ToListAsync();
|
||||||
|
List<TasksVM> tasks = new List<TasksVM>();
|
||||||
|
foreach (var workItem in workItems)
|
||||||
|
{
|
||||||
|
foreach (var taskAllocation in taskAllocations)
|
||||||
|
{
|
||||||
|
var result = new TasksVM
|
||||||
|
{
|
||||||
|
Id = workItem.ActivityMaster.Id,
|
||||||
|
ActivityName = workItem.ActivityMaster.ActivityName,
|
||||||
|
TotalPlannedTask = workItem.PlannedWork,
|
||||||
|
PlannedTask = taskAllocation.PlannedTask,
|
||||||
|
CompletedTask = taskAllocation.CompletedTask,
|
||||||
|
TotalCopmletedTask = workItem.CompletedWork
|
||||||
|
};
|
||||||
|
tasks.Add(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(tasks, "Success", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("get/{taskId}")]
|
[HttpGet("get/{taskId}")]
|
||||||
public ActionResult GetTask()
|
public async Task<IActionResult> GetTask(long taskId)
|
||||||
{
|
{
|
||||||
return Ok();
|
if (taskId == 0) return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", "Invalid data", 400));
|
||||||
|
|
||||||
|
var taskAllocation = await _context.TaskAllocations.Include(t => t.Tenant).Include(t => t.Employee).Include(t => t.WorkItem).FirstOrDefaultAsync(t => t.Id == taskId);
|
||||||
|
if (taskAllocation != null && taskAllocation.Employee != null && taskAllocation.Tenant != null)
|
||||||
|
{
|
||||||
|
//var employee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == taskAllocation.AssignedBy);
|
||||||
|
string employeeName = System.String.Format("{0} {1}", taskAllocation.Employee.FirstName, taskAllocation.Employee.LastName);
|
||||||
|
string tenantName = taskAllocation.Tenant.ContactName;
|
||||||
|
|
||||||
|
if (taskAllocation == null) return NotFound(ApiResponse<object>.ErrorResponse("Task Not Found", "Task not found", 404));
|
||||||
|
var taskVM = taskAllocation.TaskAllocationToTaskVM(employeeName,tenantName);
|
||||||
|
var comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
||||||
|
var team = await _context.TaskMembers.Where(m => m.TaskAllocationId == taskAllocation.Id).Include(m => m.Employee).ToListAsync();
|
||||||
|
var teamMembers = new List<EmployeeVM> { };
|
||||||
|
foreach(var member in team)
|
||||||
|
{
|
||||||
|
var result = member.Employee.ToEmployeeVMFromEmployee();
|
||||||
|
teamMembers.Add(result);
|
||||||
|
}
|
||||||
|
taskVM.Comments = comments;
|
||||||
|
taskVM.TeamMembers = teamMembers;
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(taskVM, "Success", 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return NotFound(ApiResponse<object>.ErrorResponse("Task Not Found", "Task not Found", 404));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,20 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return BadRequest(ModelState);
|
var errors = ModelState.Values
|
||||||
|
.SelectMany(v => v.Errors)
|
||||||
|
.Select(e => e.ErrorMessage)
|
||||||
|
.ToList();
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = await _userHelper.GetCurrentUserAsync();
|
var user = await _userHelper.GetCurrentUserAsync();
|
||||||
Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id);
|
Employee emp = new Employee { };
|
||||||
|
if(user != null)
|
||||||
|
{
|
||||||
|
emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id);
|
||||||
|
}
|
||||||
|
|
||||||
List<FeaturePermission> featurePermission = await _rolesHelper.GetFeaturePermissionByEmployeeID(emp.Id);
|
List<FeaturePermission> featurePermission = await _rolesHelper.GetFeaturePermissionByEmployeeID(emp.Id);
|
||||||
string[] projectsId = [];
|
string[] projectsId = [];
|
||||||
@ -54,16 +63,18 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
List<ProjectAllocation> allocation = await _projectsHelper.GetProjectByEmployeeID(emp.Id);
|
List<ProjectAllocation> allocation = await _projectsHelper.GetProjectByEmployeeID(emp.Id);
|
||||||
projectsId = allocation.Select(c => c.ProjectId.ToString()).ToArray();
|
projectsId = allocation.Select(c => c.ProjectId.ToString()).ToArray();
|
||||||
}
|
}
|
||||||
|
EmployeeProfile profile = new EmployeeProfile() { };
|
||||||
|
if (featurePermission != null)
|
||||||
|
{
|
||||||
EmployeeVM employeeVM = EmployeeMapper.ToEmployeeVMFromEmployee(emp);
|
EmployeeVM employeeVM = EmployeeMapper.ToEmployeeVMFromEmployee(emp);
|
||||||
EmployeeProfile profile = new EmployeeProfile()
|
profile = new EmployeeProfile()
|
||||||
{
|
{
|
||||||
EmployeeInfo = employeeVM,
|
EmployeeInfo = employeeVM,
|
||||||
Projects = projectsId,
|
Projects = projectsId,
|
||||||
FeaturePermissions = featurePermission.Select(c => c.Id.ToString()).Distinct().ToArray(),
|
FeaturePermissions = featurePermission.Select(c => c.Id.ToString()).Distinct().ToArray(),
|
||||||
Features = featurePermission.Select(c => c.FeatureId.ToString()).Distinct().ToArray(),
|
Features = featurePermission.Select(c => c.FeatureId.ToString()).Distinct().ToArray(),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(profile, "Success", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(profile, "Success", 200));
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
using Marco.Pms.Model.Dtos.Employees;
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Model.Dtos.Employees;
|
||||||
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Helpers
|
namespace MarcoBMS.Services.Helpers
|
||||||
@ -9,11 +12,13 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
{
|
{
|
||||||
private readonly UserManager<IdentityUser> _userManager;
|
private readonly UserManager<IdentityUser> _userManager;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public UserHelper(UserManager<IdentityUser> userManager, IHttpContextAccessor httpContextAccessor)
|
public UserHelper(UserManager<IdentityUser> userManager, IHttpContextAccessor httpContextAccessor,ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetTenantId()
|
public int GetTenantId()
|
||||||
@ -31,6 +36,12 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
var user = await _userManager.FindByEmailAsync(userId);
|
var user = await _userManager.FindByEmailAsync(userId);
|
||||||
return user; //await _userManager.FindByIdAsync(userId);
|
return user; //await _userManager.FindByIdAsync(userId);
|
||||||
}
|
}
|
||||||
|
public async Task<Employee> GetCurrentEmployeeAsync()
|
||||||
|
{
|
||||||
|
var user = await GetCurrentUserAsync();
|
||||||
|
var Employee = await _context.Employees.FirstOrDefaultAsync(e => e.ApplicationUserId == user.Id);
|
||||||
|
return Employee;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<object?> GetCurrentUserProfileAsync()
|
public async Task<object?> GetCurrentUserProfileAsync()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Utility
|
namespace Marco.Pms.Utility
|
||||||
{
|
{
|
||||||
@ -19,8 +14,11 @@ namespace Marco.Pms.Utility
|
|||||||
{
|
{
|
||||||
return Activator.CreateInstance<T>();
|
return Activator.CreateInstance<T>();
|
||||||
}
|
}
|
||||||
return JsonConvert.DeserializeObject<T>(json);
|
var result = JsonConvert.DeserializeObject<T>(json);
|
||||||
|
if (result == null) {
|
||||||
|
return Activator.CreateInstance<T>();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user