Removed Possible null refreance warnings
This commit is contained in:
parent
54b43b742a
commit
00951ab92f
@ -34,7 +34,10 @@ namespace Marco.Pms.DataAccess.Initializer
|
|||||||
_db.Database.Migrate();
|
_db.Database.Migrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { }
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
// Create roes if not created
|
// Create roes if not created
|
||||||
|
|
||||||
@ -64,7 +67,7 @@ namespace Marco.Pms.DataAccess.Initializer
|
|||||||
|
|
||||||
}, "User@123").GetAwaiter().GetResult();
|
}, "User@123").GetAwaiter().GetResult();
|
||||||
|
|
||||||
ApplicationUser user = _db.ApplicationUsers.FirstOrDefault(u => u.Email == "admin@marcobms.com");
|
ApplicationUser user = _db.ApplicationUsers.FirstOrDefault(u => u.Email == "admin@marcobms.com") ?? new ApplicationUser();
|
||||||
_userManager.AddToRoleAsync(user, APP_ROLES.Admin.ToString()).GetAwaiter().GetResult();
|
_userManager.AddToRoleAsync(user, APP_ROLES.Admin.ToString()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
Employee emp = new Employee()
|
Employee emp = new Employee()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Marco.Pms.Model.AttendanceModule;
|
using Marco.Pms.Model.AttendanceModule;
|
||||||
|
using Marco.Pms.Model.ViewModels.Activities;
|
||||||
using Marco.Pms.Model.ViewModels.AttendanceVM;
|
using Marco.Pms.Model.ViewModels.AttendanceVM;
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Mapper
|
namespace Marco.Pms.Model.Mapper
|
||||||
@ -11,15 +12,15 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
{
|
{
|
||||||
Id = attendanceLog.Id,
|
Id = attendanceLog.Id,
|
||||||
Comment = attendanceLog.Comment,
|
Comment = attendanceLog.Comment,
|
||||||
Employee = attendanceLog.Employee.ToBasicEmployeeVMFromEmployee(),
|
Employee = attendanceLog.Employee != null ? attendanceLog.Employee.ToBasicEmployeeVMFromEmployee() : new BasicEmployeeVM(),
|
||||||
ActivityTime = attendanceLog.ActivityTime,
|
ActivityTime = attendanceLog.ActivityTime,
|
||||||
Activity = attendanceLog.Activity,
|
Activity = attendanceLog.Activity,
|
||||||
Photo = attendanceLog.Photo,
|
Photo = attendanceLog.Photo,
|
||||||
Latitude = attendanceLog.Latitude,
|
Latitude = attendanceLog.Latitude,
|
||||||
Longitude = attendanceLog.Longitude,
|
Longitude = attendanceLog.Longitude,
|
||||||
UpdatedOn = attendanceLog.UpdatedOn,
|
UpdatedOn = attendanceLog.UpdatedOn,
|
||||||
UpdatedByEmployee = attendanceLog.UpdatedByEmployee.ToBasicEmployeeVMFromEmployee(),
|
UpdatedByEmployee = attendanceLog.UpdatedByEmployee != null ? attendanceLog.UpdatedByEmployee.ToBasicEmployeeVMFromEmployee() : new BasicEmployeeVM(),
|
||||||
DocumentId = attendanceLog.Document.Id,
|
DocumentId = attendanceLog.Document != null ? attendanceLog.Document.Id : null,
|
||||||
PreSignedUrl = preSignedUrl,
|
PreSignedUrl = preSignedUrl,
|
||||||
ThumbPreSignedUrl = thumbPreSignedUrl,
|
ThumbPreSignedUrl = thumbPreSignedUrl,
|
||||||
};
|
};
|
||||||
|
@ -126,9 +126,9 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
CreatedAt = ticket.CreatedAt,
|
CreatedAt = ticket.CreatedAt,
|
||||||
LinkedProjectId = ticket.LinkedProjectId,
|
LinkedProjectId = ticket.LinkedProjectId,
|
||||||
LinkedActivityId = ticket.LinkedActivityId,
|
LinkedActivityId = ticket.LinkedActivityId,
|
||||||
Status = ticket.TicketStatusMaster.ToTicketStatusVMFromTicketStatusMaster(),
|
Status = ticket.TicketStatusMaster != null ? ticket.TicketStatusMaster.ToTicketStatusVMFromTicketStatusMaster() : new TicketStatusVM(),
|
||||||
Priority = ticket.Priority.ToTicketPriorityVMFromTicketPriorityMaster(),
|
Priority = ticket.Priority != null ? ticket.Priority.ToTicketPriorityVMFromTicketPriorityMaster() : new TicketPriorityVM(),
|
||||||
Type = ticket.TicketTypeMaster.ToTicketTypeVMFromTicketTypeMaster(),
|
Type = ticket.TicketTypeMaster != null ? ticket.TicketTypeMaster.ToTicketTypeVMFromTicketTypeMaster() : new TicketTypeVM(),
|
||||||
CreatedBy = employee.ToBasicEmployeeVMFromEmployee(),
|
CreatedBy = employee.ToBasicEmployeeVMFromEmployee(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace Marco.Pms.Model.ViewModels.AttendanceVM
|
|||||||
|
|
||||||
public DateTime UpdatedOn { get; set; }
|
public DateTime UpdatedOn { get; set; }
|
||||||
public BasicEmployeeVM? UpdatedByEmployee { get; set; }
|
public BasicEmployeeVM? UpdatedByEmployee { get; set; }
|
||||||
public Guid DocumentId { get; set; }
|
public Guid? DocumentId { get; set; }
|
||||||
public string? PreSignedUrl { get; set; }
|
public string? PreSignedUrl { get; set; }
|
||||||
public string? ThumbPreSignedUrl { get; set; }
|
public string? ThumbPreSignedUrl { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Marco.Pms.DataAccess.Data;
|
using System.Net;
|
||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
using Marco.Pms.Model.Authentication;
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Dtos;
|
using Marco.Pms.Model.Dtos;
|
||||||
using Marco.Pms.Model.Dtos.Util;
|
using Marco.Pms.Model.Dtos.Util;
|
||||||
@ -10,7 +11,6 @@ using MarcoBMS.Services.Service;
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Controllers
|
namespace MarcoBMS.Services.Controllers
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
var user = await _context.ApplicationUsers.FirstOrDefaultAsync(u => u.Email == loginDto.Username || u.PhoneNumber == loginDto.Username);
|
var user = await _context.ApplicationUsers.FirstOrDefaultAsync(u => u.Email == loginDto.Username || u.PhoneNumber == loginDto.Username);
|
||||||
|
|
||||||
if (user != null && await _userManager.CheckPasswordAsync(user, loginDto.Password))
|
if (user != null && await _userManager.CheckPasswordAsync(user, loginDto.Password ?? string.Empty))
|
||||||
{
|
{
|
||||||
if (!user.IsActive)
|
if (!user.IsActive)
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
await _refreshTokenService.MarkRefreshTokenAsUsed(refreshToken);
|
await _refreshTokenService.MarkRefreshTokenAsUsed(refreshToken);
|
||||||
|
|
||||||
// Generate new JWT token and refresh token
|
// Generate new JWT token and refresh token
|
||||||
var user = await _userManager.FindByIdAsync(refreshToken.UserId);
|
var user = await _userManager.FindByIdAsync(refreshToken.UserId ?? string.Empty);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid request.", "Invalid request.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid request.", "Invalid request.", 400));
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
[HttpPost("reset-password")]
|
[HttpPost("reset-password")]
|
||||||
public async Task<IActionResult> ResetPassword([FromBody] ResetPasswordDto model)
|
public async Task<IActionResult> ResetPassword([FromBody] ResetPasswordDto model)
|
||||||
{
|
{
|
||||||
var user = await _userManager.FindByEmailAsync(model.Email);
|
var user = await _userManager.FindByEmailAsync(model.Email ?? string.Empty);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid request.", "Invalid request.", 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid request.", "Invalid request.", 400));
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var result = await _userManager.ResetPasswordAsync(user, token, model.NewPassword);
|
var result = await _userManager.ResetPasswordAsync(user, token, model.NewPassword ?? string.Empty);
|
||||||
if (!result.Succeeded)
|
if (!result.Succeeded)
|
||||||
{
|
{
|
||||||
var errors = result.Errors.Select(e => e.Description).ToList();
|
var errors = result.Errors.Select(e => e.Description).ToList();
|
||||||
@ -192,10 +192,11 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id);
|
Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id);
|
||||||
await _emailSender.SendResetPasswordSuccessEmail(user.Email, emp.FirstName + " " + emp.LastName);
|
await _emailSender.SendResetPasswordSuccessEmail(user.Email ?? string.Empty, emp.FirstName + " " + emp.LastName);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, ex.Message, 400));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var user = await _userManager.FindByEmailAsync(emailDot.ToEmail);
|
var user = await _userManager.FindByEmailAsync(emailDot.ToEmail ?? string.Empty);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
return NotFound(ApiResponse<object>.ErrorResponse("User not found.", "User not found.", 404));
|
return NotFound(ApiResponse<object>.ErrorResponse("User not found.", "User not found.", 404));
|
||||||
|
@ -36,7 +36,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
}
|
}
|
||||||
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 (firstTask == null) firstTask = new { TenantId = tenantId, AssignmentDate = DateTime.UtcNow };
|
||||||
|
|
||||||
|
|
||||||
if (days >= 0)
|
if (days >= 0)
|
||||||
@ -59,7 +59,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
ProjectProgressionVM.ProjectId = projectId;
|
ProjectProgressionVM.ProjectId = projectId;
|
||||||
ProjectProgressionVM.ProjectName = "";
|
ProjectProgressionVM.ProjectName = "";
|
||||||
var date = fromDate.AddDays(flagDays);
|
var date = fromDate.AddDays(flagDays);
|
||||||
if (date >= firstTask.AssignmentDate.Date)
|
if (date >= (firstTask != null ? firstTask.AssignmentDate.Date : null))
|
||||||
{
|
{
|
||||||
var todayTasks = tasks.Where(t => t.AssignmentDate.Date == date.Date).ToList();
|
var todayTasks = tasks.Where(t => t.AssignmentDate.Date == date.Date).ToList();
|
||||||
double plannedTaks = 0;
|
double plannedTaks = 0;
|
||||||
@ -104,7 +104,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
projectProgressionVM.ProjectId = projectId;
|
projectProgressionVM.ProjectId = projectId;
|
||||||
projectProgressionVM.ProjectName = project.Name;
|
projectProgressionVM.ProjectName = project.Name;
|
||||||
var date = fromDate.AddDays(flagDays);
|
var date = fromDate.AddDays(flagDays);
|
||||||
if (date >= firstTask.AssignmentDate.Date)
|
if (date >= (firstTask != null ? firstTask.AssignmentDate.Date : null))
|
||||||
{
|
{
|
||||||
var todayTasks = tasks.Where(t => t.AssignmentDate.Date == date.Date).ToList();
|
var todayTasks = tasks.Where(t => t.AssignmentDate.Date == date.Date).ToList();
|
||||||
double plannedTaks = 0;
|
double plannedTaks = 0;
|
||||||
|
@ -68,8 +68,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
Id = mapping.Id,
|
Id = mapping.Id,
|
||||||
EmployeeId = mapping.EmployeeId,
|
EmployeeId = mapping.EmployeeId,
|
||||||
Name = mapping.Role.Role,
|
Name = mapping.Role != null ? mapping.Role.Role : null,
|
||||||
Description = mapping.Role.Description,
|
Description = mapping.Role != null ? mapping.Role.Description : null,
|
||||||
IsEnabled = mapping.IsEnabled,
|
IsEnabled = mapping.IsEnabled,
|
||||||
RoleId = mapping.RoleId,
|
RoleId = mapping.RoleId,
|
||||||
});
|
});
|
||||||
@ -107,7 +107,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
if (existingItem == null)
|
if (existingItem == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
_context.EmployeeRoleMappings.Add(mapping);
|
if (role.IsEnabled == true)
|
||||||
|
{
|
||||||
|
_context.EmployeeRoleMappings.Add(mapping);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (role.IsEnabled == false)
|
else if (role.IsEnabled == false)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
// [Authorize]
|
// [Authorize]
|
||||||
public class FeatureController : ControllerBase
|
public class FeatureController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
@ -27,12 +27,14 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
private ICollection<FeaturePermissionVM> GetFeaturePermissionVMs(Feature model)
|
private ICollection<FeaturePermissionVM> GetFeaturePermissionVMs(Feature model)
|
||||||
{
|
{
|
||||||
ICollection<FeaturePermissionVM> features = [];
|
ICollection<FeaturePermissionVM> features = [];
|
||||||
foreach (FeaturePermission permission in model.FeaturePermissions)
|
if (model.FeaturePermissions != null)
|
||||||
{
|
{
|
||||||
FeaturePermissionVM item = permission.ToFeaturePermissionVMFromFeaturePermission();
|
foreach (FeaturePermission permission in model.FeaturePermissions)
|
||||||
features.Add(item);
|
{
|
||||||
|
FeaturePermissionVM item = permission.ToFeaturePermissionVMFromFeaturePermission();
|
||||||
|
features.Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
Description = c.Description,
|
Description = c.Description,
|
||||||
FeaturePermissions = GetFeaturePermissionVMs(c),
|
FeaturePermissions = GetFeaturePermissionVMs(c),
|
||||||
ModuleId = c.ModuleId,
|
ModuleId = c.ModuleId,
|
||||||
ModuleName = c.Module.Name,
|
ModuleName = c.Module != null ? c.Module.Name : string.Empty,
|
||||||
IsActive = c.IsActive
|
IsActive = c.IsActive
|
||||||
});
|
});
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(rolesVM, "Success.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(rolesVM, "Success.", 200));
|
||||||
|
@ -47,8 +47,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||||
}
|
}
|
||||||
int tenantId = _userHelper.GetTenantId();
|
int tenantId = _userHelper.GetTenantId();
|
||||||
//if (tenantId == createTicketDto.TenantId)
|
|
||||||
//{
|
|
||||||
TicketForum ticketForum = createTicketDto.ToTicketForumFromCreateTicketDto(tenantId);
|
TicketForum ticketForum = createTicketDto.ToTicketForumFromCreateTicketDto(tenantId);
|
||||||
_context.Tickets.Add(ticketForum);
|
_context.Tickets.Add(ticketForum);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@ -108,7 +106,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
Employee? employee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == ticketForum.CreatedById);
|
Employee? employee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == ticketForum.CreatedById);
|
||||||
|
|
||||||
|
|
||||||
ForumTicketVM ticketVM = ticket.ToForumTicketVMFromTicketForum(employee);
|
ForumTicketVM ticketVM = ticket != null && employee != null ? ticket.ToForumTicketVMFromTicketForum(employee) : new ForumTicketVM();
|
||||||
|
|
||||||
ticketVM.Tags = tagVMs;
|
ticketVM.Tags = tagVMs;
|
||||||
|
|
||||||
@ -140,9 +138,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
}
|
}
|
||||||
_logger.LogInfo("Ticket created by Employee {EmployeeId} for project {ProjectId}", ticketForum.CreatedById, project.Id);
|
_logger.LogInfo("Ticket created by Employee {EmployeeId} for project {ProjectId}", ticketForum.CreatedById, project.Id);
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(ticketVM, "Ticket Created Successfully", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(ticketVM, "Ticket Created Successfully", 200));
|
||||||
//}
|
|
||||||
//_logger.LogWarning("Employee {EmployeeId} tries to create ticket in different Tenant", createTicketDto.CreatedById);
|
|
||||||
// return Unauthorized(ApiResponse<object>.ErrorResponse("Not Authorized", "Not Authorized", 401));
|
|
||||||
}
|
}
|
||||||
[HttpPost("ticket/edit")]
|
[HttpPost("ticket/edit")]
|
||||||
public async Task<IActionResult> UpdateNewTicket([FromBody] UpdateTicketDto updateTicketDto)
|
public async Task<IActionResult> UpdateNewTicket([FromBody] UpdateTicketDto updateTicketDto)
|
||||||
@ -173,26 +168,30 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
|
|
||||||
List<TicketAttachment> existingAttachments = await _context.TicketAttachments.Where(a => a.TicketId == updateTicketDto.Id).ToListAsync();
|
List<TicketAttachment> existingAttachments = await _context.TicketAttachments.Where(a => a.TicketId == updateTicketDto.Id).ToListAsync();
|
||||||
var existingattachmentids = existingAttachments.Select(a => a.Id).ToList();
|
var existingattachmentids = existingAttachments.Select(a => a.Id).ToList();
|
||||||
var attachmentDtoids = updateTicketDto.Attachments.Select(a => a.Id).ToList();
|
List<Guid> attachmentDtoids = new List<Guid>();
|
||||||
foreach (var attachmentDto in updateTicketDto.Attachments)
|
if (updateTicketDto.Attachments != null)
|
||||||
{
|
{
|
||||||
if (!existingattachmentids.Contains(attachmentDto.Id) && attachmentDto.TicketId != updateTicketDto.Id)
|
attachmentDtoids = updateTicketDto.Attachments.Select(a => a.Id).ToList();
|
||||||
|
foreach (var attachmentDto in updateTicketDto.Attachments)
|
||||||
{
|
{
|
||||||
var Image = attachmentDto;
|
if (!existingattachmentids.Contains(attachmentDto.Id) && attachmentDto.TicketId != updateTicketDto.Id)
|
||||||
if (string.IsNullOrEmpty(Image.Base64Data))
|
|
||||||
{
|
{
|
||||||
_logger.LogError("Base64 data is missing");
|
var Image = attachmentDto;
|
||||||
return BadRequest(ApiResponse<object>.ErrorResponse("Base64 data is missing", "Base64 data is missing", 400));
|
if (string.IsNullOrEmpty(Image.Base64Data))
|
||||||
|
{
|
||||||
|
_logger.LogError("Base64 data is missing");
|
||||||
|
return BadRequest(ApiResponse<object>.ErrorResponse("Base64 data is missing", "Base64 data is missing", 400));
|
||||||
|
}
|
||||||
|
|
||||||
|
var objectKey = await _s3Service.UploadFileAsync(Image.Base64Data, tenantId, "forum");
|
||||||
|
|
||||||
|
Document document = attachmentDto.ToDocumentFromUpdateAttachmentDto(objectKey, objectKey, updateTicketDto.CreatedAt, tenantId);
|
||||||
|
_context.Documents.Add(document);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var attachment = attachmentDto.ToTicketAttachmentFromUpdateAttachmentDto(ticketForum.Id, document.Id);
|
||||||
|
attachments.Add(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
var objectKey = await _s3Service.UploadFileAsync(Image.Base64Data, tenantId, "forum");
|
|
||||||
|
|
||||||
Document document = attachmentDto.ToDocumentFromUpdateAttachmentDto(objectKey, objectKey, updateTicketDto.CreatedAt, tenantId);
|
|
||||||
_context.Documents.Add(document);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var attachment = attachmentDto.ToTicketAttachmentFromUpdateAttachmentDto(ticketForum.Id, document.Id);
|
|
||||||
attachments.Add(attachment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attachments.Count != 0)
|
if (attachments.Count != 0)
|
||||||
@ -213,7 +212,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<TicketTag> existingTicketTags = await _context.TicketTags.Where(t => t.TicketId == updateTicketDto.Id).ToListAsync();
|
List<TicketTag> existingTicketTags = await _context.TicketTags.Where(t => t.TicketId == updateTicketDto.Id).ToListAsync();
|
||||||
List<TicketTagMaster>? tagMasters = await _context.TicketTagMasters.Where(t => updateTicketDto.TagIds.Contains(t.Id)).ToListAsync();
|
List<TicketTagMaster>? tagMasters = await _context.TicketTagMasters.Where(t => updateTicketDto.TagIds != null ? updateTicketDto.TagIds.Contains(t.Id) : false).ToListAsync();
|
||||||
var existingTicketTagIds = existingTicketTags.Select(t => t.TagId).ToList();
|
var existingTicketTagIds = existingTicketTags.Select(t => t.TagId).ToList();
|
||||||
|
|
||||||
foreach (var ticketTag in tagMasters)
|
foreach (var ticketTag in tagMasters)
|
||||||
@ -237,7 +236,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
{
|
{
|
||||||
_context.TicketTags.AddRange(ticketTags);
|
_context.TicketTags.AddRange(ticketTags);
|
||||||
}
|
}
|
||||||
var deletedTicketTags = existingTicketTags.Where(t => !updateTicketDto.TagIds.Contains(t.TagId)).ToList();
|
var deletedTicketTags = existingTicketTags.Where(t => updateTicketDto.TagIds != null ? !updateTicketDto.TagIds.Contains(t.TagId) : true).ToList();
|
||||||
if (deletedTicketTags.Count != 0)
|
if (deletedTicketTags.Count != 0)
|
||||||
{
|
{
|
||||||
_context.TicketTags.RemoveRange(deletedTicketTags);
|
_context.TicketTags.RemoveRange(deletedTicketTags);
|
||||||
@ -245,60 +244,66 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var ticket = await _context.Tickets.Include(t => t.TicketTypeMaster).Include(t => t.TicketStatusMaster).Include(t => t.Priority).FirstOrDefaultAsync(t => t.Id == ticketForum.Id);
|
var ticket = await _context.Tickets.Include(t => t.TicketTypeMaster).Include(t => t.TicketStatusMaster).Include(t => t.Priority).FirstOrDefaultAsync(t => t.Id == ticketForum.Id);
|
||||||
|
ForumTicketVM ticketVM = new ForumTicketVM();
|
||||||
List<TicketComment> comments = await _context.TicketComments.Where(c => c.TicketId == ticket.Id).ToListAsync();
|
if (ticket != null)
|
||||||
var authorIds = comments.Select(c => c.AuthorId.ToString()).ToList();
|
|
||||||
|
|
||||||
List<Employee>? employees = await _context.Employees.Where(e => e.Id == ticketForum.CreatedById || authorIds.Contains(e.ApplicationUserId ?? "")).ToListAsync();
|
|
||||||
|
|
||||||
Employee employee = employees.Find(e => e.Id == ticketForum.CreatedById);
|
|
||||||
ForumTicketVM ticketVM = ticket.ToForumTicketVMFromTicketForum(employee);
|
|
||||||
|
|
||||||
ticketVM.Tags = tagVMs;
|
|
||||||
|
|
||||||
List<TicketCommentVM> commentVMs = new List<TicketCommentVM>();
|
|
||||||
foreach (var comment in comments)
|
|
||||||
{
|
{
|
||||||
employee = employees.Find(e => e.ApplicationUserId == comment.AuthorId.ToString()) ?? new Employee();
|
List<TicketComment> comments = await _context.TicketComments.Where(c => c.TicketId == ticket.Id).ToListAsync();
|
||||||
commentVMs.Add(comment.ToTicketCommentVMFromTicketComment(employee));
|
var authorIds = comments.Select(c => c.AuthorId.ToString()).ToList();
|
||||||
}
|
|
||||||
|
|
||||||
attachments = await _context.TicketAttachments.Where(a => a.TicketId == updateTicketDto.Id).ToListAsync();
|
List<Employee>? employees = await _context.Employees.Where(e => e.Id == ticketForum.CreatedById || authorIds.Contains(e.ApplicationUserId ?? "")).ToListAsync();
|
||||||
var fileIds = attachments.Select(a => a.FileId).ToList();
|
|
||||||
List<Document> documents = await _context.Documents.Where(d => fileIds.Contains(d.Id)).ToListAsync();
|
Employee employee = employees.Find(e => e.Id == ticketForum.CreatedById) ?? new Employee();
|
||||||
List<TicketAttachmentVM> ticketAttachmentVMs = new List<TicketAttachmentVM>();
|
ticketVM = ticket.ToForumTicketVMFromTicketForum(employee);
|
||||||
foreach (var attachment in attachments)
|
|
||||||
{
|
ticketVM.Tags = tagVMs;
|
||||||
var document = documents.Find(d => d.Id == attachment.FileId);
|
|
||||||
string preSignedUrl = string.Empty;
|
List<TicketCommentVM> commentVMs = new List<TicketCommentVM>();
|
||||||
if (document != null)
|
foreach (var comment in comments)
|
||||||
{
|
{
|
||||||
preSignedUrl = _s3Service.GeneratePreSignedUrlAsync(document.S3Key);
|
employee = employees.Find(e => e.ApplicationUserId == comment.AuthorId.ToString()) ?? new Employee();
|
||||||
|
commentVMs.Add(comment.ToTicketCommentVMFromTicketComment(employee));
|
||||||
}
|
}
|
||||||
if (attachment.CommentId == null)
|
|
||||||
|
attachments = await _context.TicketAttachments.Where(a => a.TicketId == updateTicketDto.Id).ToListAsync();
|
||||||
|
var fileIds = attachments.Select(a => a.FileId).ToList();
|
||||||
|
List<Document> documents = await _context.Documents.Where(d => fileIds.Contains(d.Id)).ToListAsync();
|
||||||
|
List<TicketAttachmentVM> ticketAttachmentVMs = new List<TicketAttachmentVM>();
|
||||||
|
foreach (var attachment in attachments)
|
||||||
{
|
{
|
||||||
ticketAttachmentVMs.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
var document = documents.Find(d => d.Id == attachment.FileId);
|
||||||
|
string preSignedUrl = string.Empty;
|
||||||
|
if (document != null)
|
||||||
|
{
|
||||||
|
preSignedUrl = _s3Service.GeneratePreSignedUrlAsync(document.S3Key);
|
||||||
|
}
|
||||||
|
if (attachment.CommentId == null)
|
||||||
|
{
|
||||||
|
ticketAttachmentVMs.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
||||||
|
if (commentVM != null && commentVM.Attachments != null)
|
||||||
|
{
|
||||||
|
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
ticketVM.Comments = commentVMs;
|
||||||
|
ticketVM.Attachments = ticketAttachmentVMs;
|
||||||
|
Project project = await _context.Projects.FirstOrDefaultAsync(p => p.Id == ticketForum.LinkedProjectId) ?? new Project();
|
||||||
|
ticketVM.ProjectName = project.Name;
|
||||||
|
if (updateTicketDto.LinkedActivityId != null && updateTicketDto.LinkedActivityId != 0)
|
||||||
{
|
{
|
||||||
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
WorkItem workItem = await _context.WorkItems.Include(w => w.ActivityMaster).FirstOrDefaultAsync(w => w.Id == ticketForum.LinkedActivityId) ?? new WorkItem();
|
||||||
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
if (workItem.ActivityMaster != null)
|
||||||
}
|
{
|
||||||
}
|
ticketVM.ActivityName = workItem.ActivityMaster.ActivityName;
|
||||||
ticketVM.Comments = commentVMs;
|
}
|
||||||
ticketVM.Attachments = ticketAttachmentVMs;
|
else
|
||||||
Project project = await _context.Projects.FirstOrDefaultAsync(p => p.Id == ticketForum.LinkedProjectId) ?? new Project();
|
{
|
||||||
ticketVM.ProjectName = project.Name;
|
ticketVM.ActivityName = "";
|
||||||
if (updateTicketDto.LinkedActivityId != null && updateTicketDto.LinkedActivityId != 0)
|
}
|
||||||
{
|
|
||||||
WorkItem workItem = await _context.WorkItems.Include(w => w.ActivityMaster).FirstOrDefaultAsync(w => w.Id == ticketForum.LinkedActivityId) ?? new WorkItem();
|
|
||||||
if (workItem.ActivityMaster != null)
|
|
||||||
{
|
|
||||||
ticketVM.ActivityName = workItem.ActivityMaster.ActivityName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ticketVM.ActivityName = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logger.LogInfo("Ticket {TicketId} updated", updateTicketDto.Id);
|
_logger.LogInfo("Ticket {TicketId} updated", updateTicketDto.Id);
|
||||||
@ -584,7 +589,10 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
||||||
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
if (commentVM != null && commentVM.Attachments != null)
|
||||||
|
{
|
||||||
|
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ticketVM.Comments = commentVMs;
|
ticketVM.Comments = commentVMs;
|
||||||
@ -603,7 +611,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
ticketVM.ActivityName = "";
|
ticketVM.ActivityName = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logger.LogInfo("Status of Ticket {TicketId} in project {ProjectId} is changes to {status}", id, ticket.LinkedProjectId, ticket.TicketStatusMaster.Name);
|
_logger.LogInfo("Status of Ticket {TicketId} in project {ProjectId} is changes to {status}", id, ticket.LinkedProjectId, ticket.TicketStatusMaster != null ? ticket.TicketStatusMaster.Name : string.Empty);
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(ticketVM, "Ticket Fetched Successfully", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(ticketVM, "Ticket Fetched Successfully", 200));
|
||||||
}
|
}
|
||||||
[HttpGet("ticket/{id}")]
|
[HttpGet("ticket/{id}")]
|
||||||
@ -659,7 +667,10 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
||||||
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
if (commentVM != null && commentVM.Attachments != null)
|
||||||
|
{
|
||||||
|
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ticketVM.Comments = commentVMs;
|
ticketVM.Comments = commentVMs;
|
||||||
@ -695,7 +706,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
List<TicketComment> ticketComments = await _context.TicketComments.Where(c => ticketIds.Contains(c.TicketId)).ToListAsync();
|
List<TicketComment> ticketComments = await _context.TicketComments.Where(c => ticketIds.Contains(c.TicketId)).ToListAsync();
|
||||||
var authorIds = ticketComments.Select(c => c.AuthorId.ToString()).ToList();
|
var authorIds = ticketComments.Select(c => c.AuthorId.ToString()).ToList();
|
||||||
|
|
||||||
List<Employee> employees = await _context.Employees.Where(e => createdByIds.Contains(e.Id) || authorIds.Contains(e.ApplicationUserId)).ToListAsync();
|
List<Employee> employees = await _context.Employees.Where(e => createdByIds.Contains(e.Id) || (e.ApplicationUserId != null && authorIds.Contains(e.ApplicationUserId))).ToListAsync();
|
||||||
|
|
||||||
var ticketTags = await _context.TicketTags.Where(t => ticketIds.Contains(t.TicketId)).ToListAsync();
|
var ticketTags = await _context.TicketTags.Where(t => ticketIds.Contains(t.TicketId)).ToListAsync();
|
||||||
List<Guid> tagIds = ticketTags.Select(t => t.TagId).ToList();
|
List<Guid> tagIds = ticketTags.Select(t => t.TagId).ToList();
|
||||||
@ -758,7 +769,10 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
var commentVM = commentVMs.Find(c => c.Id == attachment.CommentId);
|
||||||
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
if (commentVM != null && commentVM.Attachments != null)
|
||||||
|
{
|
||||||
|
commentVM.Attachments.Add(attachment.ToTicketAttachmentVMFromTicketAttachment(preSignedUrl, preSignedUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ticketVM.Comments = commentVMs;
|
ticketVM.Comments = commentVMs;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using Marco.Pms.DataAccess.Data;
|
||||||
using System.ComponentModel;
|
|
||||||
using Marco.Pms.DataAccess.Data;
|
|
||||||
using Marco.Pms.Model.Dtos.Project;
|
using Marco.Pms.Model.Dtos.Project;
|
||||||
using Marco.Pms.Model.Employees;
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
@ -12,7 +10,6 @@ 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;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Controllers
|
namespace MarcoBMS.Services.Controllers
|
||||||
@ -25,7 +22,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
//private readonly IUnitOfWork _unitOfWork;
|
//private readonly IUnitOfWork _unitOfWork;
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
//private ApplicationUser _applicationUser;
|
//private ApplicationUser _applicationUser;
|
||||||
// private readonly IProjectRepository _projectrepo;
|
// private readonly IProjectRepository _projectrepo;
|
||||||
//private readonly UserManager<IdentityUser> _userManager;
|
//private readonly UserManager<IdentityUser> _userManager;
|
||||||
private readonly UserHelper _userHelper;
|
private readonly UserHelper _userHelper;
|
||||||
|
|
||||||
@ -34,7 +31,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
//_unitOfWork = unitOfWork;
|
//_unitOfWork = unitOfWork;
|
||||||
_context = context;
|
_context = context;
|
||||||
//_projectrepo = projectrepo;
|
//_projectrepo = projectrepo;
|
||||||
//_userManager = userManager;
|
//_userManager = userManager;
|
||||||
_userHelper = userHelper;
|
_userHelper = userHelper;
|
||||||
}
|
}
|
||||||
@ -51,7 +48,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
var tenantId = _userHelper.GetTenantId();
|
var tenantId = _userHelper.GetTenantId();
|
||||||
List<Project> projects = await _context.Projects.Where(c=>c.TenantId == _userHelper.GetTenantId()).ToListAsync();
|
List<Project> projects = await _context.Projects.Where(c => c.TenantId == _userHelper.GetTenantId()).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
List<ProjectListVM> response = new List<ProjectListVM>();
|
List<ProjectListVM> response = new List<ProjectListVM>();
|
||||||
@ -120,7 +117,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var project = await _context.Projects.Where(c => c.TenantId == _userHelper.GetTenantId() && c.Id == id).Include(c=> c.ProjectStatus).SingleOrDefaultAsync(); // includeProperties: "ProjectStatus,Tenant"); //_context.Stock.FindAsync(id);
|
var project = await _context.Projects.Where(c => c.TenantId == _userHelper.GetTenantId() && c.Id == id).Include(c => c.ProjectStatus).SingleOrDefaultAsync(); // includeProperties: "ProjectStatus,Tenant"); //_context.Stock.FindAsync(id);
|
||||||
|
|
||||||
if (project == null)
|
if (project == null)
|
||||||
{
|
{
|
||||||
@ -133,7 +130,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
ProjectDetailsVM vm = await GetProjectViewModel(id, project);
|
ProjectDetailsVM vm = await GetProjectViewModel(id, project);
|
||||||
|
|
||||||
ProjectVM projectVM = new ProjectVM();
|
ProjectVM projectVM = new ProjectVM();
|
||||||
if (vm.project != null) {
|
if (vm.project != null)
|
||||||
|
{
|
||||||
projectVM.Id = vm.project.Id;
|
projectVM.Id = vm.project.Id;
|
||||||
projectVM.Name = vm.project.Name;
|
projectVM.Name = vm.project.Name;
|
||||||
projectVM.ProjectAddress = vm.project.ProjectAddress;
|
projectVM.ProjectAddress = vm.project.ProjectAddress;
|
||||||
@ -143,7 +141,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
projectVM.ProjectStatusId = vm.project.ProjectStatusId;
|
projectVM.ProjectStatusId = vm.project.ProjectStatusId;
|
||||||
}
|
}
|
||||||
projectVM.Buildings = new List<BuildingVM>();
|
projectVM.Buildings = new List<BuildingVM>();
|
||||||
if (vm.buildings != null) {
|
if (vm.buildings != null)
|
||||||
|
{
|
||||||
foreach (Building build in vm.buildings)
|
foreach (Building build in vm.buildings)
|
||||||
{
|
{
|
||||||
BuildingVM buildVM = new BuildingVM() { Id = build.Id, Description = build.Description, Name = build.Name };
|
BuildingVM buildVM = new BuildingVM() { Id = build.Id, Description = build.Description, Name = build.Name };
|
||||||
@ -161,7 +160,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
WorkAreaVM workAreaVM = new WorkAreaVM() { Id = workAreaDto.Id, AreaName = workAreaDto.AreaName, WorkItems = new List<WorkItemVM>() };
|
WorkAreaVM workAreaVM = new WorkAreaVM() { Id = workAreaDto.Id, AreaName = workAreaDto.AreaName, WorkItems = new List<WorkItemVM>() };
|
||||||
|
|
||||||
if(vm.workItems != null)
|
if (vm.workItems != null)
|
||||||
{
|
{
|
||||||
foreach (WorkItem workItemDto in vm.workItems.Where(c => c.WorkAreaId == workAreaDto.Id).ToList())
|
foreach (WorkItem workItemDto in vm.workItems.Where(c => c.WorkAreaId == workAreaDto.Id).ToList())
|
||||||
{
|
{
|
||||||
@ -169,7 +168,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
//workItemVM.WorkItem.WorkArea = null
|
//workItemVM.WorkItem.WorkArea = null
|
||||||
workItemVM.WorkItem.WorkArea = new WorkArea();
|
workItemVM.WorkItem.WorkArea = new WorkArea();
|
||||||
//workItemVM.WorkItem.ActivityMaster.Tenant = null;
|
//workItemVM.WorkItem.ActivityMaster.Tenant = null;
|
||||||
workItemVM.WorkItem.ActivityMaster.Tenant = new Tenant();
|
if (workItemVM.WorkItem.ActivityMaster != null)
|
||||||
|
{
|
||||||
|
workItemVM.WorkItem.ActivityMaster.Tenant = new Tenant();
|
||||||
|
}
|
||||||
//workItemVM.WorkItem.Tenant = null;
|
//workItemVM.WorkItem.Tenant = null;
|
||||||
workItemVM.WorkItem.Tenant = new Tenant();
|
workItemVM.WorkItem.Tenant = new Tenant();
|
||||||
|
|
||||||
@ -183,10 +185,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildVM.Floors.Add(floorVM);
|
buildVM.Floors.Add(floorVM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
projectVM.Buildings.Add(buildVM);
|
projectVM.Buildings.Add(buildVM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(projectVM, "Success.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(projectVM, "Success.", 200));
|
||||||
@ -210,8 +212,8 @@ 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 = workAreas.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();
|
||||||
|
|
||||||
vm.project = project;
|
vm.project = project;
|
||||||
vm.buildings = buildings;
|
vm.buildings = buildings;
|
||||||
@ -270,7 +272,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
int TenantId = GetTenantId();
|
int TenantId = GetTenantId();
|
||||||
updateProjectDto.TenantId = TenantId;
|
updateProjectDto.TenantId = TenantId;
|
||||||
|
|
||||||
Project project = updateProjectDto.ToProjectFromUpdateProjectDto(TenantId,id);
|
Project project = updateProjectDto.ToProjectFromUpdateProjectDto(TenantId, id);
|
||||||
_context.Projects.Update(project);
|
_context.Projects.Update(project);
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@ -357,7 +359,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
join fp in _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectid)
|
join fp in _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectid)
|
||||||
on rpm.Id equals fp.EmployeeId
|
on rpm.Id equals fp.EmployeeId
|
||||||
select rpm).ToListAsync();
|
select rpm).ToListAsync();
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result = await (from rpm in _context.Employees.Include(c => c.JobRole)
|
result = await (from rpm in _context.Employees.Include(c => c.JobRole)
|
||||||
join fp in _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectid && c.IsActive == true)
|
join fp in _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectid && c.IsActive == true)
|
||||||
@ -398,19 +401,22 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
int TenantId = GetTenantId();
|
int TenantId = GetTenantId();
|
||||||
|
|
||||||
|
|
||||||
var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectId).Include(e => e.Employee).Include(e => e.Employee.JobRole).Select(e => new
|
var employees = await _context.ProjectAllocations
|
||||||
{
|
.Where(c => c.TenantId == TenantId && c.ProjectId == projectId && c.Employee != null)
|
||||||
ID = e.Id,
|
.Include(e => e.Employee)
|
||||||
EmployeeId = e.EmployeeId,
|
.Select(e => new
|
||||||
ProjectId = e.ProjectId,
|
{
|
||||||
AllocationDate = e.AllocationDate,
|
ID = e.Id,
|
||||||
ReAllocationDate = e.ReAllocationDate,
|
EmployeeId = e.EmployeeId,
|
||||||
FirstName = e.Employee.FirstName,
|
ProjectId = e.ProjectId,
|
||||||
LastName = e.Employee.LastName,
|
AllocationDate = e.AllocationDate,
|
||||||
MiddleName = e.Employee.MiddleName,
|
ReAllocationDate = e.ReAllocationDate,
|
||||||
IsActive = e.IsActive,
|
FirstName = e.Employee != null ? e.Employee.FirstName : string.Empty,
|
||||||
JobRoleId = (e.JobRoleId != null ? e.JobRoleId : e.Employee.JobRoleId)
|
LastName = e.Employee != null ? e.Employee.LastName : string.Empty,
|
||||||
}).ToListAsync();
|
MiddleName = e.Employee != null ? e.Employee.MiddleName : string.Empty,
|
||||||
|
IsActive = e.IsActive,
|
||||||
|
JobRoleId = (e.JobRoleId != null ? e.JobRoleId : e.Employee != null ? e.Employee.JobRoleId : null)
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(employees, "Success.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(employees, "Success.", 200));
|
||||||
}
|
}
|
||||||
@ -474,15 +480,16 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
return Ok(ApiResponse<object>.ErrorResponse(ex.Message,ex, 400));
|
{
|
||||||
|
return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(result, "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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +508,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
//update
|
//update
|
||||||
_context.WorkItems.Update(workItem);
|
_context.WorkItems.Update(workItem);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -526,7 +533,7 @@ 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{ };
|
var responseData = new InfraVM { };
|
||||||
if (infraDots != null)
|
if (infraDots != null)
|
||||||
{
|
{
|
||||||
foreach (var item in infraDots)
|
foreach (var item in infraDots)
|
||||||
|
@ -28,7 +28,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
public TaskController(ApplicationDbContext context, UserHelper userHelper)
|
public TaskController(ApplicationDbContext context, UserHelper userHelper)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_userHelper = userHelper;
|
_userHelper = userHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetTenantId()
|
private int GetTenantId()
|
||||||
@ -51,7 +51,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
var tenantId = GetTenantId();
|
var tenantId = GetTenantId();
|
||||||
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
var taskAllocation = assignTask.ToTaskAllocationFromAssignTaskDto(Employee.Id,tenantId);
|
var taskAllocation = assignTask.ToTaskAllocationFromAssignTaskDto(Employee.Id, tenantId);
|
||||||
_context.TaskAllocations.Add(taskAllocation);
|
_context.TaskAllocations.Add(taskAllocation);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
var response = taskAllocation.ToAssignTaskVMFromTaskAllocation();
|
var response = taskAllocation.ToAssignTaskVMFromTaskAllocation();
|
||||||
@ -74,9 +74,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var idList = teamMembers.Select(m => m.EmployeeId);
|
var idList = teamMembers.Select(m => m.EmployeeId);
|
||||||
List<Employee> employees = await _context.Employees.Where(e=> idList.Contains(e.Id)).ToListAsync();
|
List<Employee> employees = await _context.Employees.Where(e => idList.Contains(e.Id)).ToListAsync();
|
||||||
List<EmployeeVM> team = new List<EmployeeVM>();
|
List<EmployeeVM> team = new List<EmployeeVM>();
|
||||||
foreach (var employee in employees) {
|
foreach (var employee in employees)
|
||||||
|
{
|
||||||
team.Add(employee.ToEmployeeVMFromEmployee());
|
team.Add(employee.ToEmployeeVMFromEmployee());
|
||||||
}
|
}
|
||||||
response.teamMembers = team;
|
response.teamMembers = team;
|
||||||
@ -85,7 +86,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
|
|
||||||
[HttpPost("report")]
|
[HttpPost("report")]
|
||||||
public async Task<IActionResult> ReportTaskProgress([FromBody]ReportTaskDto reportTask)
|
public async Task<IActionResult> ReportTaskProgress([FromBody] ReportTaskDto reportTask)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
@ -101,12 +102,13 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
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 checkListIds = reportTask.CheckList != null ? reportTask.CheckList.Select(c => c.Id).ToList() : new List<int>();
|
||||||
var checkList = await _context.ActivityCheckLists.Where(c => checkListIds.Contains(c.Id)).ToListAsync();
|
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));
|
||||||
}
|
}
|
||||||
if(taskAllocation.WorkItem != null)
|
if (taskAllocation.WorkItem != null)
|
||||||
{
|
{
|
||||||
if (taskAllocation.CompletedTask != 0)
|
if (taskAllocation.CompletedTask != 0)
|
||||||
{
|
{
|
||||||
@ -118,33 +120,36 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
List<CheckListMappings> checkListMappings = new List<CheckListMappings>();
|
List<CheckListMappings> checkListMappings = new List<CheckListMappings>();
|
||||||
List<CheckListVM> checkListVMs = new List<CheckListVM>();
|
List<CheckListVM> checkListVMs = new List<CheckListVM>();
|
||||||
foreach (var checkDto in reportTask.CheckList)
|
if (reportTask.CheckList != null)
|
||||||
{
|
{
|
||||||
checkListVMs.Add(checkDto.ToCheckListVMFromReportCheckListDto(taskAllocation.WorkItem.ActivityId));
|
foreach (var checkDto in reportTask.CheckList)
|
||||||
if (checkDto.IsChecked)
|
|
||||||
{
|
{
|
||||||
var check = checkList.Find(c => c.Id == checkDto.Id);
|
checkListVMs.Add(checkDto.ToCheckListVMFromReportCheckListDto(taskAllocation.WorkItem != null ? taskAllocation.WorkItem.ActivityId : 0));
|
||||||
if (check != null)
|
if (checkDto.IsChecked)
|
||||||
{
|
{
|
||||||
CheckListMappings checkListMapping = new CheckListMappings
|
var check = checkList.Find(c => c.Id == checkDto.Id);
|
||||||
|
if (check != null)
|
||||||
{
|
{
|
||||||
CheckListId = check.Id,
|
CheckListMappings checkListMapping = new CheckListMappings
|
||||||
TaskAllocationId = reportTask.Id
|
{
|
||||||
};
|
CheckListId = check.Id,
|
||||||
checkListMappings.Add(checkListMapping);
|
TaskAllocationId = reportTask.Id
|
||||||
|
};
|
||||||
|
checkListMappings.Add(checkListMapping);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_context.CheckListMappings.AddRange(checkListMappings);
|
_context.CheckListMappings.AddRange(checkListMappings);
|
||||||
var comment = reportTask.ToCommentFromReportTaskDto(tenantId,Employee.Id);
|
var comment = reportTask.ToCommentFromReportTaskDto(tenantId, Employee.Id);
|
||||||
|
|
||||||
_context.TaskComments.Add(comment);
|
_context.TaskComments.Add(comment);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var response = taskAllocation.ToReportTaskVMFromTaskAllocation();
|
var response = taskAllocation.ToReportTaskVMFromTaskAllocation();
|
||||||
List < TaskComment > comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
List<TaskComment> comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
||||||
List < CommentVM > resultComments = new List<CommentVM> { };
|
List<CommentVM> resultComments = new List<CommentVM> { };
|
||||||
foreach(var result in comments)
|
foreach (var result in comments)
|
||||||
{
|
{
|
||||||
resultComments.Add(result.ToCommentVMFromTaskComment());
|
resultComments.Add(result.ToCommentVMFromTaskComment());
|
||||||
}
|
}
|
||||||
@ -154,7 +159,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("comment")]
|
[HttpPost("comment")]
|
||||||
public async Task<IActionResult> AddCommentForTask([FromBody]CreateCommentDto createComment )
|
public async Task<IActionResult> AddCommentForTask([FromBody] CreateCommentDto createComment)
|
||||||
{
|
{
|
||||||
var tenantId = GetTenantId();
|
var tenantId = GetTenantId();
|
||||||
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
var Employee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
@ -202,7 +207,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
idList = workItems.Select(i => i.Id).ToList();
|
idList = workItems.Select(i => i.Id).ToList();
|
||||||
var activityIdList = workItems.Select(i => i.ActivityId).ToList();
|
var activityIdList = workItems.Select(i => i.ActivityId).ToList();
|
||||||
|
|
||||||
List<TaskAllocation> taskAllocations = await _context.TaskAllocations.Where(t => idList.Contains(t.WorkItemId) && t.AssignmentDate.Date >= fromDate.Date && t.AssignmentDate.Date <= toDate.Date && t.TenantId == tenantId).Include(t => t.WorkItem).Include(t=>t.Employee).ToListAsync();
|
List<TaskAllocation> taskAllocations = await _context.TaskAllocations.Where(t => idList.Contains(t.WorkItemId) && t.AssignmentDate.Date >= fromDate.Date && t.AssignmentDate.Date <= toDate.Date && t.TenantId == tenantId).Include(t => t.WorkItem).Include(t => t.Employee).ToListAsync();
|
||||||
var taskIdList = taskAllocations.Select(t => t.Id).ToList();
|
var taskIdList = taskAllocations.Select(t => t.Id).ToList();
|
||||||
|
|
||||||
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();
|
||||||
@ -213,47 +218,48 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
List<ListTaskVM> tasks = new List<ListTaskVM>();
|
List<ListTaskVM> tasks = new List<ListTaskVM>();
|
||||||
//foreach (var workItem in workItems)
|
//foreach (var workItem in workItems)
|
||||||
//{
|
//{
|
||||||
foreach (var taskAllocation in taskAllocations)
|
foreach (var taskAllocation in taskAllocations)
|
||||||
|
{
|
||||||
|
|
||||||
|
var response = taskAllocation.ToListTaskVMFromTaskAllocation();
|
||||||
|
|
||||||
|
List<TaskComment> comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
||||||
|
List<BasicEmployeeVM> team = new List<BasicEmployeeVM>();
|
||||||
|
List<TaskMembers> taskMembers = teamMembers.Where(m => m.TaskAllocationId == taskAllocation.Id).ToList();
|
||||||
|
|
||||||
|
foreach (var taskMember in taskMembers)
|
||||||
{
|
{
|
||||||
|
|
||||||
var response = taskAllocation.ToListTaskVMFromTaskAllocation();
|
|
||||||
|
|
||||||
List<TaskComment> comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
|
||||||
List<BasicEmployeeVM> team = new List<BasicEmployeeVM>();
|
|
||||||
List<TaskMembers> taskMembers = teamMembers.Where(m => m.TaskAllocationId == taskAllocation.Id).ToList();
|
|
||||||
|
|
||||||
foreach (var taskMember in taskMembers)
|
|
||||||
{
|
|
||||||
var teamMember = employees.Find(e => e.Id == taskMember.EmployeeId);
|
var teamMember = employees.Find(e => e.Id == taskMember.EmployeeId);
|
||||||
if(teamMember != null)
|
if (teamMember != null)
|
||||||
{
|
|
||||||
team.Add(teamMember.ToBasicEmployeeVMFromEmployee());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<CommentVM> commentVM = new List<CommentVM> { };
|
|
||||||
foreach (var comment in comments)
|
|
||||||
{
|
{
|
||||||
commentVM.Add(comment.ToCommentVMFromTaskComment());
|
team.Add(teamMember.ToBasicEmployeeVMFromEmployee());
|
||||||
}
|
}
|
||||||
List<ActivityCheckList> checkLists = await _context.ActivityCheckLists.Where(x => x.ActivityId == 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) {
|
|
||||||
var checkListMapping = checkListMappings.Find(c => c.CheckListId == check.Id);
|
|
||||||
if(checkListMapping != null)
|
|
||||||
{
|
|
||||||
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityId, true));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityId, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response.comments = commentVM;
|
|
||||||
response.teamMembers = team;
|
|
||||||
response.CheckList = checkList;
|
|
||||||
tasks.Add(response);
|
|
||||||
}
|
}
|
||||||
|
List<CommentVM> commentVM = new List<CommentVM> { };
|
||||||
|
foreach (var comment in comments)
|
||||||
|
{
|
||||||
|
commentVM.Add(comment.ToCommentVMFromTaskComment());
|
||||||
|
}
|
||||||
|
List<ActivityCheckList> checkLists = await _context.ActivityCheckLists.Where(x => x.ActivityId == (taskAllocation.WorkItem != null ? taskAllocation.WorkItem.ActivityId : 0)).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)
|
||||||
|
{
|
||||||
|
var checkListMapping = checkListMappings.Find(c => c.CheckListId == check.Id);
|
||||||
|
if (checkListMapping != null)
|
||||||
|
{
|
||||||
|
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityId, true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkList.Add(check.ToCheckListVMFromActivityCheckList(check.ActivityId, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.comments = commentVM;
|
||||||
|
response.teamMembers = team;
|
||||||
|
response.CheckList = checkList;
|
||||||
|
tasks.Add(response);
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(tasks, "Success", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(tasks, "Success", 200));
|
||||||
@ -269,16 +275,16 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
//var employee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == taskAllocation.AssignedBy);
|
//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 employeeName = System.String.Format("{0} {1}", taskAllocation.Employee.FirstName, taskAllocation.Employee.LastName);
|
||||||
string tenantName = taskAllocation.Tenant.ContactName;
|
string tenantName = taskAllocation.Tenant.ContactName ?? string.Empty;
|
||||||
|
|
||||||
if (taskAllocation == null) return NotFound(ApiResponse<object>.ErrorResponse("Task Not Found", "Task not found", 404));
|
if (taskAllocation == null) return NotFound(ApiResponse<object>.ErrorResponse("Task Not Found", "Task not found", 404));
|
||||||
var taskVM = taskAllocation.TaskAllocationToTaskVM(employeeName,tenantName);
|
var taskVM = taskAllocation.TaskAllocationToTaskVM(employeeName, tenantName);
|
||||||
var comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
|
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 team = await _context.TaskMembers.Where(m => m.TaskAllocationId == taskAllocation.Id).Include(m => m.Employee).ToListAsync();
|
||||||
var teamMembers = new List<EmployeeVM> { };
|
var teamMembers = new List<EmployeeVM> { };
|
||||||
foreach(var member in team)
|
foreach (var member in team)
|
||||||
{
|
{
|
||||||
var result = member.Employee.ToEmployeeVMFromEmployee();
|
var result = member.Employee != null ? member.Employee.ToEmployeeVMFromEmployee() : new EmployeeVM();
|
||||||
teamMembers.Add(result);
|
teamMembers.Add(result);
|
||||||
}
|
}
|
||||||
List<CommentVM> Comments = new List<CommentVM> { };
|
List<CommentVM> Comments = new List<CommentVM> { };
|
||||||
|
@ -49,7 +49,7 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
result = await (from pa in _context.ProjectAllocations.Where(c => c.ProjectId == ProjectId)
|
result = await (from pa in _context.ProjectAllocations.Where(c => c.ProjectId == ProjectId)
|
||||||
join em in _context.Employees.Where(c => c.TenantId == TenentId).Include(fp => fp.JobRole) // Include Feature
|
join em in _context.Employees.Where(c => c.TenantId == TenentId).Include(fp => fp.JobRole) // Include Feature
|
||||||
on pa.EmployeeId equals em.Id
|
on pa.EmployeeId equals em.Id
|
||||||
where em.FirstName.ToLower().Contains(searchString.ToLower()) || em.LastName.ToLower().Contains(searchString.ToLower())
|
where (em.FirstName != null ? em.FirstName.ToLower().Contains(searchString.ToLower()) : false) || (em.LastName != null ? em.LastName.ToLower().Contains(searchString.ToLower()) : false)
|
||||||
select em.ToEmployeeVMFromEmployee()
|
select em.ToEmployeeVMFromEmployee()
|
||||||
)
|
)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@ -58,7 +58,7 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = await _context.Employees.Where(c => c.TenantId == TenentId &&
|
result = await _context.Employees.Where(c => c.TenantId == TenentId &&
|
||||||
(c.FirstName.ToLower().Contains(searchString.ToLower()) || c.LastName.ToLower().Contains(searchString.ToLower()))).Include(fp => fp.JobRole)
|
((c.FirstName != null ? c.FirstName.ToLower().Contains(searchString.ToLower()) : false) || (c.LastName != null ? c.LastName.ToLower().Contains(searchString.ToLower()) : false))).Include(fp => fp.JobRole)
|
||||||
.Select(c => c.ToEmployeeVMFromEmployee()).ToListAsync();
|
.Select(c => c.ToEmployeeVMFromEmployee()).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ builder.Host.UseSerilog((context, config) =>
|
|||||||
{
|
{
|
||||||
config.ReadFrom.Configuration(context.Configuration) // Taking all configuration from appsetting.json
|
config.ReadFrom.Configuration(context.Configuration) // Taking all configuration from appsetting.json
|
||||||
.WriteTo.MongoDB(
|
.WriteTo.MongoDB(
|
||||||
databaseUrl: mongoConn,
|
databaseUrl: mongoConn ?? string.Empty,
|
||||||
collectionName: "api-logs",
|
collectionName: "api-logs",
|
||||||
batchPostingLimit: 100,
|
batchPostingLimit: 100,
|
||||||
period: timeSpan
|
period: timeSpan
|
||||||
@ -133,7 +133,9 @@ builder.Services.AddSingleton<ILoggingService, LoggingService>();
|
|||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
var jwtSettings = builder.Configuration.GetSection("Jwt").Get<JwtSettings>();
|
var jwtSettings = builder.Configuration.GetSection("Jwt").Get<JwtSettings>()
|
||||||
|
?? throw new InvalidOperationException("JwtSettings section is missing or invalid.");
|
||||||
|
|
||||||
if (jwtSettings != null && jwtSettings.Key != null)
|
if (jwtSettings != null && jwtSettings.Key != null)
|
||||||
{
|
{
|
||||||
builder.Services.AddAuthentication(options =>
|
builder.Services.AddAuthentication(options =>
|
||||||
@ -154,9 +156,9 @@ if (jwtSettings != null && jwtSettings.Key != null)
|
|||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Key))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Key))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
builder.Services.AddSingleton(jwtSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Services.AddSingleton(jwtSettings);
|
|
||||||
builder.WebHost.ConfigureKestrel(options =>
|
builder.WebHost.ConfigureKestrel(options =>
|
||||||
{
|
{
|
||||||
options.AddServerHeader = false; // Disable the "Server" header
|
options.AddServerHeader = false; // Disable the "Server" header
|
||||||
|
@ -95,13 +95,13 @@ namespace MarcoBMS.Services.Service
|
|||||||
var replacements = new Dictionary<string, string>
|
var replacements = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "MAIL_TITLE", "User Requested a Demo" },
|
{ "MAIL_TITLE", "User Requested a Demo" },
|
||||||
{ "ORGANIZATION_NAME", demoEmailObject.OrganizatioinName },
|
{ "ORGANIZATION_NAME", demoEmailObject.OrganizatioinName ?? string.Empty },
|
||||||
{ "EMAIL", demoEmailObject.Email },
|
{ "EMAIL", demoEmailObject.Email ?? string.Empty},
|
||||||
{ "ABOUT", demoEmailObject.About },
|
{ "ABOUT", demoEmailObject.About ?? string.Empty },
|
||||||
{ "ORGANIZATION_SIZE", demoEmailObject.OragnizationSize },
|
{ "ORGANIZATION_SIZE", demoEmailObject.OragnizationSize ?? string.Empty },
|
||||||
{ "INDUSTRY_NAME", demoEmailObject.IndustryName },
|
{ "INDUSTRY_NAME", demoEmailObject.IndustryName ?? string.Empty },
|
||||||
{ "CONTACT_NAME", demoEmailObject.ContactPerson },
|
{ "CONTACT_NAME", demoEmailObject.ContactPerson ?? string.Empty },
|
||||||
{ "CONTACT_NUMBER", demoEmailObject.ContactNumber }
|
{ "CONTACT_NUMBER", demoEmailObject.ContactNumber ?? string.Empty }
|
||||||
};
|
};
|
||||||
string emailBody = await GetEmailTemplate("request-demo", replacements);
|
string emailBody = await GetEmailTemplate("request-demo", replacements);
|
||||||
|
|
||||||
|
@ -221,14 +221,14 @@ namespace Marco.Pms.Services.Service
|
|||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
// Handle cases where the input string is not valid Base64
|
// Handle cases where the input string is not valid Base64
|
||||||
Console.WriteLine("Error: Invalid Base64 string.");
|
_logger.LogError("Invalid Base64 string.");
|
||||||
return null;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// Handle other potential errors during decoding or inspection
|
// Handle other potential errors during decoding or inspection
|
||||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
_logger.LogError($"An error occurred: {ex.Message}");
|
||||||
return null;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user