Added checklist to report api
This commit is contained in:
parent
dbc1b721c1
commit
cac50a3f06
10
Marco.Pms.Model/Dtos/Activities/ReportCheckListDto.cs
Normal file
10
Marco.Pms.Model/Dtos/Activities/ReportCheckListDto.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Marco.Pms.Model.Dtos.Activities
|
||||||
|
{
|
||||||
|
public class ReportCheckListDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Check { get; set; }
|
||||||
|
public bool IsMandatory { get; set; }
|
||||||
|
public bool IsChecked { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -6,5 +6,6 @@
|
|||||||
public double CompletedTask { get; set; }
|
public double CompletedTask { get; set; }
|
||||||
public DateTime ReportedDate { get; set; }
|
public DateTime ReportedDate { get; set; }
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
public List<ReportCheckListDto>? CheckList { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,18 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
}
|
}
|
||||||
public static BasicEmployeeVM ToBasicEmployeeVMFromEmployee(this Employee employee)
|
public static BasicEmployeeVM ToBasicEmployeeVMFromEmployee(this Employee employee)
|
||||||
{
|
{
|
||||||
|
if (employee.JobRole == null)
|
||||||
|
{
|
||||||
|
return new BasicEmployeeVM
|
||||||
|
{
|
||||||
|
Id = employee.Id,
|
||||||
|
FirstName = employee.FirstName,
|
||||||
|
LastName = employee.LastName,
|
||||||
|
Photo = employee.Photo,
|
||||||
|
JobRoleId = employee.JobRoleId,
|
||||||
|
JobRoleName = ""
|
||||||
|
};
|
||||||
|
}
|
||||||
return new BasicEmployeeVM
|
return new BasicEmployeeVM
|
||||||
{
|
{
|
||||||
Id = employee.Id,
|
Id = employee.Id,
|
||||||
|
@ -34,9 +34,9 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid starting date.", "Invalid starting date.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid starting date.", "Invalid starting date.", 400));
|
||||||
|
|
||||||
}
|
}
|
||||||
var firstTask = await _context.TaskAllocations.Select(t => new {t.TenantId,t.AssignmentDate}).FirstOrDefaultAsync(t => t.TenantId == tenantId);
|
var firstTask = await _context.TaskAllocations.Select(t => new { t.TenantId, t.AssignmentDate }).FirstOrDefaultAsync(t => t.TenantId == tenantId);
|
||||||
if (FromDate == null) fromDate = DateTime.UtcNow.Date;
|
if (FromDate == null) fromDate = DateTime.UtcNow.Date;
|
||||||
|
if (firstTask == null) firstTask = new{ TenantId = tenantId, AssignmentDate = DateTime.UtcNow};
|
||||||
|
|
||||||
|
|
||||||
if (days >= 0)
|
if (days >= 0)
|
||||||
@ -44,7 +44,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
double negativeDays = 0 - days;
|
double negativeDays = 0 - days;
|
||||||
toDate = fromDate.AddDays(negativeDays);
|
toDate = fromDate.AddDays(negativeDays);
|
||||||
|
|
||||||
if (firstTask.AssignmentDate.Date >= toDate.Date)
|
if (firstTask != null && (firstTask.AssignmentDate.Date >= toDate.Date))
|
||||||
{
|
{
|
||||||
toDate = firstTask.AssignmentDate;
|
toDate = firstTask.AssignmentDate;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
/* SEND USER REGISTRATION MAIL*/
|
/* SEND USER REGISTRATION MAIL*/
|
||||||
var token = await _userManager.GeneratePasswordResetTokenAsync(user);
|
var token = await _userManager.GeneratePasswordResetTokenAsync(user);
|
||||||
var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}";
|
var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}";
|
||||||
await _emailSender.SendResetPasswordEmailOnRegister(user.Email, newEmployee.FirstName, resetLink);
|
if (newEmployee.FirstName != null)
|
||||||
|
{
|
||||||
|
await _emailSender.SendResetPasswordEmailOnRegister(user.Email, newEmployee.FirstName, resetLink);
|
||||||
|
}
|
||||||
|
|
||||||
responsemessage = "User created successfully. Password reset link is sent to registered email";
|
responsemessage = "User created successfully. Password reset link is sent to registered email";
|
||||||
}
|
}
|
||||||
@ -265,8 +268,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create Employee record if missing
|
// Create Employee record if missing
|
||||||
Employee newEmployee = GetNewEmployeeModel(model, TenantId, null);
|
Employee newEmployee = GetNewEmployeeModel(model, TenantId, null);
|
||||||
|
|
||||||
_context.Employees.Add(newEmployee);
|
_context.Employees.Add(newEmployee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
var taskAllocation = await _context.TaskAllocations.Include(t => t.WorkItem).FirstOrDefaultAsync(t => t.Id == reportTask.Id);
|
var taskAllocation = await _context.TaskAllocations.Include(t => t.WorkItem).FirstOrDefaultAsync(t => t.Id == reportTask.Id);
|
||||||
|
|
||||||
|
var checkListIds = reportTask.CheckList.Select(c => c.Id).ToList();
|
||||||
|
var checkList = await _context.ActivityCheckLists.Where(c => checkListIds.Contains(c.Id)).ToListAsync();
|
||||||
if (taskAllocation == null) {
|
if (taskAllocation == null) {
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("No such task has been allocated.", "No such task has been allocated.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("No such task has been allocated.", "No such task has been allocated.", 400));
|
||||||
}
|
}
|
||||||
@ -113,8 +116,14 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
taskAllocation.CompletedTask = reportTask.CompletedTask;
|
taskAllocation.CompletedTask = reportTask.CompletedTask;
|
||||||
taskAllocation.WorkItem.CompletedWork += reportTask.CompletedTask;
|
taskAllocation.WorkItem.CompletedWork += reportTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
List<ActivityCheckList> activityCheckLists = new List<ActivityCheckList>();
|
||||||
|
foreach (var checkDto in reportTask.CheckList)
|
||||||
|
{
|
||||||
|
var check = checkList.Find(c => c.Id == checkDto.Id);
|
||||||
|
check.IsChecked = checkDto.IsChecked;
|
||||||
|
activityCheckLists.Add(check);
|
||||||
|
}
|
||||||
|
_context.ActivityCheckLists.UpdateRange(activityCheckLists);
|
||||||
var comment = reportTask.ToCommentFromReportTaskDto(tenantId,Employee.Id);
|
var comment = reportTask.ToCommentFromReportTaskDto(tenantId,Employee.Id);
|
||||||
|
|
||||||
_context.TaskComments.Add(comment);
|
_context.TaskComments.Add(comment);
|
||||||
@ -165,6 +174,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
if (dateFrom == null) fromDate = DateTime.UtcNow.Date;
|
if (dateFrom == null) fromDate = DateTime.UtcNow.Date;
|
||||||
if (dateTo == null) toDate = fromDate.AddDays(1);
|
if (dateTo == null) toDate = fromDate.AddDays(1);
|
||||||
|
|
||||||
|
var jobroles = await _context.JobRoles.Where(r => r.TenantId == tenantId).ToListAsync();
|
||||||
//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();
|
//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<Building> buildings = await _context.Buildings.Where(b => b.ProjectId == projectId && b.TenantId == tenantId).ToListAsync();
|
||||||
List<int> idList = buildings.Select(b => b.Id).ToList();
|
List<int> idList = buildings.Select(b => b.Id).ToList();
|
||||||
@ -185,8 +195,6 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
List<TaskMembers> teamMembers = await _context.TaskMembers.Where(t => taskIdList.Contains(t.TaskAllocationId)).ToListAsync();
|
List<TaskMembers> teamMembers = await _context.TaskMembers.Where(t => taskIdList.Contains(t.TaskAllocationId)).ToListAsync();
|
||||||
var employeeIdList = teamMembers.Select(e => e.EmployeeId).ToList();
|
var employeeIdList = teamMembers.Select(e => e.EmployeeId).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Employee> employees = await _context.Employees.Where(e => employeeIdList.Contains(e.Id)).Include(e => e.JobRole).ToListAsync();
|
List<Employee> employees = await _context.Employees.Where(e => employeeIdList.Contains(e.Id)).Include(e => e.JobRole).ToListAsync();
|
||||||
|
|
||||||
List<ListTaskVM> tasks = new List<ListTaskVM>();
|
List<ListTaskVM> tasks = new List<ListTaskVM>();
|
||||||
@ -207,7 +215,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
if(teamMember != null)
|
if(teamMember != null)
|
||||||
{
|
{
|
||||||
team.Add(teamMember.ToBasicEmployeeVMFromEmployee());
|
team.Add(teamMember.ToBasicEmployeeVMFromEmployee());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<CommentVM> commentVM = new List<CommentVM> { };
|
List<CommentVM> commentVM = new List<CommentVM> { };
|
||||||
foreach (var comment in comments)
|
foreach (var comment in comments)
|
||||||
|
@ -38,7 +38,7 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
{
|
{
|
||||||
var user = await GetCurrentUserAsync();
|
var user = await GetCurrentUserAsync();
|
||||||
if (user == null) return new Employee { };
|
if (user == null) return new Employee { };
|
||||||
var Employee = await _context.Employees.FirstOrDefaultAsync(e => e.ApplicationUserId == user.Id);
|
var Employee = await _context.Employees.Include(e => e.JobRole).FirstOrDefaultAsync(e => e.ApplicationUserId == user.Id);
|
||||||
return Employee ?? new Employee { };
|
return Employee ?? new Employee { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user