Added checklist and taskallocation relation table and logic to map taskallocation and checklist in that table in report task API
This commit is contained in:
parent
cac50a3f06
commit
1c48ab80aa
@ -73,6 +73,7 @@ namespace Marco.Pms.DataAccess.Data
|
||||
|
||||
public DbSet<Industry>Industries { get; set; }
|
||||
public DbSet<ActivityCheckList>ActivityCheckLists { get; set; }
|
||||
public DbSet<CheckListMappings> CheckListMappings { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
2092
Marco.Pms.DataAccess/Migrations/20250415111241_Added_CheckListMappings_Table.Designer.cs
generated
Normal file
2092
Marco.Pms.DataAccess/Migrations/20250415111241_Added_CheckListMappings_Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Marco.Pms.DataAccess.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Added_CheckListMappings_Table : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CheckListMappings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
TaskAllocationId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CheckListId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CheckListMappings", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CheckListMappings");
|
||||
}
|
||||
}
|
||||
}
|
@ -604,6 +604,25 @@ namespace Marco.Pms.DataAccess.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Entitlements.CheckListMappings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CheckListId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("TaskAllocationId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CheckListMappings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
9
Marco.Pms.Model/Entitlements/CheckListMappings.cs
Normal file
9
Marco.Pms.Model/Entitlements/CheckListMappings.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Entitlements
|
||||
{
|
||||
public class CheckListMappings
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public long TaskAllocationId { get; set; }
|
||||
public int CheckListId { get; set; }
|
||||
}
|
||||
}
|
@ -133,14 +133,14 @@ namespace Marco.Pms.Model.Mapper
|
||||
CheckLists = checkList,
|
||||
};
|
||||
}
|
||||
public static CheckListVM ToCheckListVMFromActivityCheckList(this ActivityCheckList checkList,int activityId)
|
||||
public static CheckListVM ToCheckListVMFromActivityCheckList(this ActivityCheckList checkList,int activityId,bool IsChecked)
|
||||
{
|
||||
return new CheckListVM
|
||||
{
|
||||
Id = checkList.Id,
|
||||
Check = checkList.Check,
|
||||
ActivityMasterId = activityId,
|
||||
IsChecked = checkList.IsChecked,
|
||||
IsChecked = IsChecked,
|
||||
IsMandatory = checkList.IsMandatory,
|
||||
};
|
||||
}
|
||||
@ -155,5 +155,16 @@ namespace Marco.Pms.Model.Mapper
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static CheckListVM ToCheckListVMFromReportCheckListDto(this ReportCheckListDto checkListDto, int activityId)
|
||||
{
|
||||
return new CheckListVM
|
||||
{
|
||||
Id = checkListDto.Id,
|
||||
Check = checkListDto.Check,
|
||||
ActivityMasterId = activityId,
|
||||
IsChecked = checkListDto.IsChecked,
|
||||
IsMandatory = checkListDto.IsMandatory,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ namespace Marco.Pms.Model.ViewModels.Activities
|
||||
public int TenantId { get; set; }
|
||||
|
||||
public List<CommentVM>? Comments { get; set; }
|
||||
public List<CheckListVM>? checkList { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace Marco.Pms.Services.Controllers
|
||||
{
|
||||
foreach (ActivityCheckList check in checkList)
|
||||
{
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activity.Id);
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activity.Id,false);
|
||||
checkListVM.Add(checkVM);
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace Marco.Pms.Services.Controllers
|
||||
List<CheckListVM> checkListVM = new List<CheckListVM>();
|
||||
foreach (ActivityCheckList check in activityCheckList)
|
||||
{
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activityMaster.Id);
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activityMaster.Id,false);
|
||||
checkListVM.Add(checkVM);
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Marco.Pms.Services.Controllers
|
||||
List<CheckListVM> checkListVM = new List<CheckListVM>();
|
||||
foreach (ActivityCheckList check in activityCheckList)
|
||||
{
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activity.Id);
|
||||
var checkVM = check.ToCheckListVMFromActivityCheckList(activity.Id, false);
|
||||
checkListVM.Add(checkVM);
|
||||
}
|
||||
|
||||
|
@ -116,14 +116,26 @@ namespace MarcoBMS.Services.Controllers
|
||||
taskAllocation.CompletedTask = reportTask.CompletedTask;
|
||||
taskAllocation.WorkItem.CompletedWork += reportTask.CompletedTask;
|
||||
}
|
||||
List<ActivityCheckList> activityCheckLists = new List<ActivityCheckList>();
|
||||
List<CheckListMappings> checkListMappings = new List<CheckListMappings>();
|
||||
List<CheckListVM> checkListVMs = new List<CheckListVM>();
|
||||
foreach (var checkDto in reportTask.CheckList)
|
||||
{
|
||||
var check = checkList.Find(c => c.Id == checkDto.Id);
|
||||
check.IsChecked = checkDto.IsChecked;
|
||||
activityCheckLists.Add(check);
|
||||
checkListVMs.Add(checkDto.ToCheckListVMFromReportCheckListDto(taskAllocation.WorkItem.ActivityId));
|
||||
if (checkDto.IsChecked)
|
||||
{
|
||||
var check = checkList.Find(c => c.Id == checkDto.Id);
|
||||
if (check != null)
|
||||
{
|
||||
CheckListMappings checkListMapping = new CheckListMappings
|
||||
{
|
||||
CheckListId = check.Id,
|
||||
TaskAllocationId = reportTask.Id
|
||||
};
|
||||
checkListMappings.Add(checkListMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
_context.ActivityCheckLists.UpdateRange(activityCheckLists);
|
||||
_context.CheckListMappings.AddRange(checkListMappings);
|
||||
var comment = reportTask.ToCommentFromReportTaskDto(tenantId,Employee.Id);
|
||||
|
||||
_context.TaskComments.Add(comment);
|
||||
@ -137,6 +149,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
resultComments.Add(result.ToCommentVMFromTaskComment());
|
||||
}
|
||||
response.Comments = resultComments;
|
||||
response.checkList = checkListVMs;
|
||||
return Ok(ApiResponse<object>.SuccessResponse(response, "Task reported successfully", 200));
|
||||
}
|
||||
|
||||
@ -223,9 +236,18 @@ namespace MarcoBMS.Services.Controllers
|
||||
commentVM.Add(comment.ToCommentVMFromTaskComment());
|
||||
}
|
||||
List<ActivityCheckList> checkLists = await _context.ActivityCheckLists.Where(x => x.ActivityMasterId == taskAllocation.WorkItem.ActivityId).ToListAsync();
|
||||
List<CheckListMappings> checkListMappings = await _context.CheckListMappings.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
||||
List<CheckListVM>checkList = new List<CheckListVM>();
|
||||
foreach (var check in checkLists) {
|
||||
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityMasterId));
|
||||
var checkListMapping = checkListMappings.Find(c => c.CheckListId == check.Id);
|
||||
if(checkListMapping != null)
|
||||
{
|
||||
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityMasterId, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityMasterId, false));
|
||||
}
|
||||
}
|
||||
response.comments = commentVM;
|
||||
response.teamMembers = team;
|
||||
|
Loading…
x
Reference in New Issue
Block a user