Compare commits
	
		
			No commits in common. "a6a842bf104eb22305a8230f0b5299f53b53388a" and "aa2bc674eb66d0d480a3c47c2d076a106c27d6b3" have entirely different histories.
		
	
	
		
			a6a842bf10
			...
			aa2bc674eb
		
	
		
@ -161,20 +161,15 @@ namespace Marco.Pms.DataAccess.Data
 | 
			
		||||
                    TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                },
 | 
			
		||||
                 new StatusMaster
 | 
			
		||||
                 {
 | 
			
		||||
                     Id = new Guid("cdad86aa-8a56-4ff4-b633-9c629057dfef"),
 | 
			
		||||
                     Status = "In Progress",
 | 
			
		||||
                     TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                 }, new StatusMaster
 | 
			
		||||
                 {
 | 
			
		||||
                     Id = new Guid("603e994b-a27f-4e5d-a251-f3d69b0498ba"),
 | 
			
		||||
                     Status = "On Hold",
 | 
			
		||||
                     Status = "In Progress",
 | 
			
		||||
                     TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                 },
 | 
			
		||||
                  new StatusMaster
 | 
			
		||||
                  {
 | 
			
		||||
                      Id = new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"),
 | 
			
		||||
                      Status = "In Active",
 | 
			
		||||
                      Status = "On Hold",
 | 
			
		||||
                      TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                  },
 | 
			
		||||
                   new StatusMaster
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,57 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace Marco.Pms.DataAccess.Migrations
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class Added_New_Status_Master_In_Progress : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.UpdateData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                keyColumn: "Id",
 | 
			
		||||
                keyValue: new Guid("603e994b-a27f-4e5d-a251-f3d69b0498ba"),
 | 
			
		||||
                column: "Status",
 | 
			
		||||
                value: "On Hold");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.UpdateData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                keyColumn: "Id",
 | 
			
		||||
                keyValue: new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"),
 | 
			
		||||
                column: "Status",
 | 
			
		||||
                value: "In Active");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.InsertData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                columns: new[] { "Id", "Status", "TenantId" },
 | 
			
		||||
                values: new object[] { new Guid("cdad86aa-8a56-4ff4-b633-9c629057dfef"), "In Progress", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DeleteData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                keyColumn: "Id",
 | 
			
		||||
                keyValue: new Guid("cdad86aa-8a56-4ff4-b633-9c629057dfef"));
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.UpdateData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                keyColumn: "Id",
 | 
			
		||||
                keyValue: new Guid("603e994b-a27f-4e5d-a251-f3d69b0498ba"),
 | 
			
		||||
                column: "Status",
 | 
			
		||||
                value: "In Progress");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.UpdateData(
 | 
			
		||||
                table: "StatusMasters",
 | 
			
		||||
                keyColumn: "Id",
 | 
			
		||||
                keyValue: new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"),
 | 
			
		||||
                column: "Status",
 | 
			
		||||
                value: "On Hold");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1683,20 +1683,14 @@ namespace Marco.Pms.DataAccess.Migrations
 | 
			
		||||
                        },
 | 
			
		||||
                        new
 | 
			
		||||
                        {
 | 
			
		||||
                            Id = new Guid("cdad86aa-8a56-4ff4-b633-9c629057dfef"),
 | 
			
		||||
                            Id = new Guid("603e994b-a27f-4e5d-a251-f3d69b0498ba"),
 | 
			
		||||
                            Status = "In Progress",
 | 
			
		||||
                            TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                        },
 | 
			
		||||
                        new
 | 
			
		||||
                        {
 | 
			
		||||
                            Id = new Guid("603e994b-a27f-4e5d-a251-f3d69b0498ba"),
 | 
			
		||||
                            Status = "On Hold",
 | 
			
		||||
                            TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                        },
 | 
			
		||||
                        new
 | 
			
		||||
                        {
 | 
			
		||||
                            Id = new Guid("ef1c356e-0fe0-42df-a5d3-8daee355492d"),
 | 
			
		||||
                            Status = "In Active",
 | 
			
		||||
                            Status = "On Hold",
 | 
			
		||||
                            TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
 | 
			
		||||
                        },
 | 
			
		||||
                        new
 | 
			
		||||
 | 
			
		||||
@ -7,13 +7,11 @@ using Marco.Pms.Model.Mapper;
 | 
			
		||||
using Marco.Pms.Model.Projects;
 | 
			
		||||
using Marco.Pms.Model.Utilities;
 | 
			
		||||
using Marco.Pms.Model.ViewModels.AttendanceVM;
 | 
			
		||||
using Marco.Pms.Services.Hubs;
 | 
			
		||||
using Marco.Pms.Services.Service;
 | 
			
		||||
using MarcoBMS.Services.Helpers;
 | 
			
		||||
using MarcoBMS.Services.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.AspNetCore.SignalR;
 | 
			
		||||
using Microsoft.CodeAnalysis;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using Document = Marco.Pms.Model.DocumentManager.Document;
 | 
			
		||||
@ -32,11 +30,10 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        private readonly S3UploadService _s3Service;
 | 
			
		||||
        private readonly PermissionServices _permission;
 | 
			
		||||
        private readonly ILoggingService _logger;
 | 
			
		||||
        private readonly IHubContext<MarcoHub> _signalR;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public AttendanceController(
 | 
			
		||||
             ApplicationDbContext context, EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper, S3UploadService s3Service, ILoggingService logger, PermissionServices permission, IHubContext<MarcoHub> signalR)
 | 
			
		||||
             ApplicationDbContext context, EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper, S3UploadService s3Service, ILoggingService logger, PermissionServices permission)
 | 
			
		||||
        {
 | 
			
		||||
            _context = context;
 | 
			
		||||
            _employeeHelper = employeeHelper;
 | 
			
		||||
@ -45,7 +42,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            _s3Service = s3Service;
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _permission = permission;
 | 
			
		||||
            _signalR = signalR;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Guid GetTenantId()
 | 
			
		||||
@ -562,13 +558,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        Activity = attendance.Activity,
 | 
			
		||||
                        JobRoleName = employee.JobRole.Name
 | 
			
		||||
                    };
 | 
			
		||||
                    var sendActivity = 0;
 | 
			
		||||
                    if (recordAttendanceDot.Id == Guid.Empty)
 | 
			
		||||
                    {
 | 
			
		||||
                        sendActivity = 1;
 | 
			
		||||
                    }
 | 
			
		||||
                    var notification = new { LoggedInUserId = currentEmployee.Id, Keyword = "Attendance", Activity = sendActivity, ProjectId = attendance.ProjectID, Response = vm };
 | 
			
		||||
                    await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
                    _logger.LogInfo("Attendance for employee {FirstName} {LastName} has been marked", employee.FirstName ?? string.Empty, employee.LastName ?? string.Empty);
 | 
			
		||||
                    return Ok(ApiResponse<object>.SuccessResponse(vm, "Attendance marked successfully.", 200));
 | 
			
		||||
                }
 | 
			
		||||
@ -731,7 +720,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                    };
 | 
			
		||||
                    _context.Documents.Add(document);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    await _context.SaveChangesAsync();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,13 +9,11 @@ using Marco.Pms.Model.Mapper;
 | 
			
		||||
using Marco.Pms.Model.Projects;
 | 
			
		||||
using Marco.Pms.Model.Utilities;
 | 
			
		||||
using Marco.Pms.Model.ViewModels.Employee;
 | 
			
		||||
using Marco.Pms.Services.Hubs;
 | 
			
		||||
using MarcoBMS.Services.Helpers;
 | 
			
		||||
using MarcoBMS.Services.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
using Microsoft.AspNetCore.Identity;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.AspNetCore.SignalR;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
 | 
			
		||||
namespace MarcoBMS.Services.Controllers
 | 
			
		||||
@ -34,11 +32,9 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        private readonly UserHelper _userHelper;
 | 
			
		||||
        private readonly IConfiguration _configuration;
 | 
			
		||||
        private readonly ILoggingService _logger;
 | 
			
		||||
        private readonly IHubContext<MarcoHub> _signalR;
 | 
			
		||||
 | 
			
		||||
        public EmployeeController(UserManager<ApplicationUser> userManager, IEmailSender emailSender,
 | 
			
		||||
            ApplicationDbContext context, EmployeeHelper employeeHelper, UserHelper userHelper, IConfiguration configuration, ILoggingService logger,
 | 
			
		||||
            IHubContext<MarcoHub> signalR)
 | 
			
		||||
            ApplicationDbContext context, EmployeeHelper employeeHelper, UserHelper userHelper, IConfiguration configuration, ILoggingService logger)
 | 
			
		||||
        {
 | 
			
		||||
            _context = context;
 | 
			
		||||
            _userManager = userManager;
 | 
			
		||||
@ -47,7 +43,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            _userHelper = userHelper;
 | 
			
		||||
            _configuration = configuration;
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _signalR = signalR;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpGet]
 | 
			
		||||
@ -159,8 +154,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        public async Task<IActionResult> CreateUser([FromBody] CreateUserDto model)
 | 
			
		||||
        {
 | 
			
		||||
            Guid tenantId = _userHelper.GetTenantId();
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
            Guid employeeId = Guid.Empty;
 | 
			
		||||
            if (model == null)
 | 
			
		||||
                return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", "Invaild Data", 400));
 | 
			
		||||
 | 
			
		||||
@ -187,7 +180,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
 | 
			
		||||
                        _context.Employees.Update(existingEmployee);
 | 
			
		||||
                        await _context.SaveChangesAsync();
 | 
			
		||||
                        employeeId = existingEmployee.Id;
 | 
			
		||||
                        responsemessage = "User updated successfully.";
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
@ -222,7 +214,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        _context.Employees.Add(newEmployee);
 | 
			
		||||
 | 
			
		||||
                        await _context.SaveChangesAsync();
 | 
			
		||||
                        employeeId = newEmployee.Id;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        /* SEND USER REGISTRATION MAIL*/
 | 
			
		||||
                        var token = await _userManager.GeneratePasswordResetTokenAsync(user);
 | 
			
		||||
@ -241,7 +233,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        _context.Employees.Update(existingEmployee);
 | 
			
		||||
                        await _context.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
                        employeeId = existingEmployee.Id;
 | 
			
		||||
 | 
			
		||||
                        /* SEND USER REGISTRATION MAIL*/
 | 
			
		||||
                        var token = await _userManager.GeneratePasswordResetTokenAsync(user);
 | 
			
		||||
@ -265,22 +256,17 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                    existingEmployee = GetUpdateEmployeeModel(model, existingEmployee);
 | 
			
		||||
                    _context.Employees.Update(existingEmployee);
 | 
			
		||||
                    responsemessage = "User updated successfully.";
 | 
			
		||||
                    employeeId = existingEmployee.Id;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    // Create Employee record if missing
 | 
			
		||||
                    Employee newEmployee = GetNewEmployeeModel(model, tenantId, string.Empty);
 | 
			
		||||
                    _context.Employees.Add(newEmployee);
 | 
			
		||||
                    employeeId = newEmployee.Id;
 | 
			
		||||
                }
 | 
			
		||||
                await _context.SaveChangesAsync();
 | 
			
		||||
                responsemessage = "User created successfully.";
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Employee", EmployeeId = employeeId };
 | 
			
		||||
 | 
			
		||||
            await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
            return Ok(ApiResponse<object>.SuccessResponse("Success.", responsemessage, 200));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -434,9 +420,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                    }
 | 
			
		||||
                    await _context.SaveChangesAsync();
 | 
			
		||||
                    _logger.LogInfo("Employee with ID {EmployeId} Deleted successfully", employee.Id);
 | 
			
		||||
                    var notification = new { LoggedInUserId = LoggedEmployee.Id, Keyword = "Employee", EmployeeId = employee.Id };
 | 
			
		||||
 | 
			
		||||
                    await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
 | 
			
		||||
@ -8,12 +8,10 @@ using Marco.Pms.Model.Projects;
 | 
			
		||||
using Marco.Pms.Model.Utilities;
 | 
			
		||||
using Marco.Pms.Model.ViewModels.Employee;
 | 
			
		||||
using Marco.Pms.Model.ViewModels.Projects;
 | 
			
		||||
using Marco.Pms.Services.Hubs;
 | 
			
		||||
using MarcoBMS.Services.Helpers;
 | 
			
		||||
using MarcoBMS.Services.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.AspNetCore.SignalR;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
 | 
			
		||||
namespace MarcoBMS.Services.Controllers
 | 
			
		||||
@ -28,18 +26,15 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        private readonly ILoggingService _logger;
 | 
			
		||||
        private readonly RolesHelper _rolesHelper;
 | 
			
		||||
        private readonly ProjectsHelper _projectsHelper;
 | 
			
		||||
        private readonly IHubContext<MarcoHub> _signalR;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public ProjectController(ApplicationDbContext context, UserHelper userHelper, ILoggingService logger, RolesHelper rolesHelper, ProjectsHelper projectHelper, IHubContext<MarcoHub> signalR)
 | 
			
		||||
        public ProjectController(ApplicationDbContext context, UserHelper userHelper, ILoggingService logger, RolesHelper rolesHelper, ProjectsHelper projectHelper)
 | 
			
		||||
        {
 | 
			
		||||
            _context = context;
 | 
			
		||||
            _userHelper = userHelper;
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _rolesHelper = rolesHelper;
 | 
			
		||||
            _projectsHelper = projectHelper;
 | 
			
		||||
            _signalR = signalR;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpGet("list/basic")]
 | 
			
		||||
@ -88,6 +83,8 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            return Ok(ApiResponse<object>.SuccessResponse(response, "Success.", 200));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [HttpGet("list")]
 | 
			
		||||
        public async Task<IActionResult> GetAll()
 | 
			
		||||
        {
 | 
			
		||||
@ -316,7 +313,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<IActionResult> Create([FromBody] CreateProjectDto projectDto)
 | 
			
		||||
        {
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
            if (!ModelState.IsValid)
 | 
			
		||||
            {
 | 
			
		||||
                var errors = ModelState.Values
 | 
			
		||||
@ -333,9 +329,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            _context.Projects.Add(project);
 | 
			
		||||
 | 
			
		||||
            await _context.SaveChangesAsync();
 | 
			
		||||
            var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Create_Project", Response = project.ToProjectDto() };
 | 
			
		||||
 | 
			
		||||
            await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
 | 
			
		||||
            return Ok(ApiResponse<object>.SuccessResponse(project.ToProjectDto(), "Success.", 200));
 | 
			
		||||
        }
 | 
			
		||||
@ -344,7 +337,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        [Route("update/{id}")]
 | 
			
		||||
        public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] UpdateProjectDto updateProjectDto)
 | 
			
		||||
        {
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
            if (!ModelState.IsValid)
 | 
			
		||||
            {
 | 
			
		||||
                var errors = ModelState.Values
 | 
			
		||||
@ -363,10 +355,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
 | 
			
		||||
                await _context.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
                var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Update_Project", Response = project.ToProjectDto() };
 | 
			
		||||
 | 
			
		||||
                await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
 | 
			
		||||
                return Ok(ApiResponse<object>.SuccessResponse(project.ToProjectDto(), "Success.", 200));
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
@ -376,6 +364,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //[HttpPost("assign-employee")]
 | 
			
		||||
        //public async Task<IActionResult> AssignEmployee(int? allocationid, int employeeId, int projectId)
 | 
			
		||||
        //{
 | 
			
		||||
@ -516,11 +505,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            if (projectAllocationDot != null)
 | 
			
		||||
            {
 | 
			
		||||
                Guid TenentID = GetTenantId();
 | 
			
		||||
                var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
 | 
			
		||||
                List<object>? result = new List<object>();
 | 
			
		||||
                List<Guid> employeeIds = new List<Guid>();
 | 
			
		||||
                List<Guid> projectIds = new List<Guid>();
 | 
			
		||||
 | 
			
		||||
                foreach (var item in projectAllocationDot)
 | 
			
		||||
                {
 | 
			
		||||
@ -549,9 +534,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                                projectAllocationFromDb.IsActive = false;
 | 
			
		||||
                                _context.Entry(projectAllocationFromDb).Property(e => e.ReAllocationDate).IsModified = true;
 | 
			
		||||
                                _context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
 | 
			
		||||
 | 
			
		||||
                                employeeIds.Add(projectAllocation.EmployeeId);
 | 
			
		||||
                                projectIds.Add(projectAllocation.ProjectId);
 | 
			
		||||
                            }
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            var result1 = new
 | 
			
		||||
@ -573,9 +555,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            projectAllocation.IsActive = true;
 | 
			
		||||
                            _context.ProjectAllocations.Add(projectAllocation);
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
                            employeeIds.Add(projectAllocation.EmployeeId);
 | 
			
		||||
                            projectIds.Add(projectAllocation.ProjectId);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
@ -584,9 +563,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Assign_Project", ProjectIds = projectIds, EmployeeList = employeeIds };
 | 
			
		||||
 | 
			
		||||
                await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
                return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
@ -610,29 +587,21 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            var workItemsToCreate = new List<WorkItem>();
 | 
			
		||||
            var workItemsToUpdate = new List<WorkItem>();
 | 
			
		||||
            var responseList = new List<WorkItemVM>();
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
            string message = "";
 | 
			
		||||
            List<Guid> projectIds = new List<Guid>();
 | 
			
		||||
 | 
			
		||||
            foreach (var itemDto in workItemDtos)
 | 
			
		||||
            {
 | 
			
		||||
                var workItem = itemDto.ToWorkItemFromWorkItemDto(tenantId);
 | 
			
		||||
                var workArea = await _context.WorkAreas.Include(a => a.Floor).FirstOrDefaultAsync(a => a.Id == workItem.WorkAreaId) ?? new WorkArea();
 | 
			
		||||
 | 
			
		||||
                Building building = await _context.Buildings.FirstOrDefaultAsync(b => b.Id == (workArea.Floor != null ? workArea.Floor.BuildingId : Guid.Empty)) ?? new Building();
 | 
			
		||||
 | 
			
		||||
                if (itemDto.Id != null && itemDto.Id != Guid.Empty)
 | 
			
		||||
                {
 | 
			
		||||
                    // Update existing
 | 
			
		||||
                    workItemsToUpdate.Add(workItem);
 | 
			
		||||
                    message = $"Task Updated in Building: {building.Name}, on Floor: {workArea.Floor?.FloorName}, in Area: {workArea.AreaName} by {LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}";
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    // Create new
 | 
			
		||||
                    workItem.Id = Guid.NewGuid();
 | 
			
		||||
                    workItemsToCreate.Add(workItem);
 | 
			
		||||
                    message = $"Task Added in Building: {building.Name}, on Floor: {workArea.Floor?.FloorName}, in Area: {workArea.AreaName} by {LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}";
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                responseList.Add(new WorkItemVM
 | 
			
		||||
@ -640,35 +609,26 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                    WorkItemId = workItem.Id,
 | 
			
		||||
                    WorkItem = workItem
 | 
			
		||||
                });
 | 
			
		||||
                projectIds.Add(building.ProjectId);
 | 
			
		||||
            }
 | 
			
		||||
            string responseMessage = "";
 | 
			
		||||
 | 
			
		||||
            // Apply DB changes
 | 
			
		||||
            if (workItemsToCreate.Any())
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInfo("Adding {Count} new work items", workItemsToCreate.Count);
 | 
			
		||||
                await _context.WorkItems.AddRangeAsync(workItemsToCreate);
 | 
			
		||||
                responseMessage = "Task Added Successfully";
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (workItemsToUpdate.Any())
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInfo("Updating {Count} existing work items", workItemsToUpdate.Count);
 | 
			
		||||
                _context.WorkItems.UpdateRange(workItemsToUpdate);
 | 
			
		||||
                responseMessage = "Task Updated Successfully";
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            await _context.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
            _logger.LogInfo("CreateProjectTask completed successfully. Created: {Created}, Updated: {Updated}", workItemsToCreate.Count, workItemsToUpdate.Count);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Infra", ProjectIds = projectIds, Message = message };
 | 
			
		||||
 | 
			
		||||
            await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
            string responseMessage = $"{(workItemsToCreate.Any() ? "Task(s) created" : "")}{(workItemsToUpdate.Any() ? (workItemsToCreate.Any() ? " and " : "") + "updated" : "")} successfully.";
 | 
			
		||||
 | 
			
		||||
            return Ok(ApiResponse<object>.SuccessResponse(responseList, responseMessage, 200));
 | 
			
		||||
        }
 | 
			
		||||
@ -677,9 +637,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        public async Task<IActionResult> DeleteProjectTask(Guid id)
 | 
			
		||||
        {
 | 
			
		||||
            Guid tenantId = _userHelper.GetTenantId();
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
            List<Guid> projectIds = new List<Guid>();
 | 
			
		||||
            WorkItem? task = await _context.WorkItems.AsNoTracking().Include(t => t.WorkArea).FirstOrDefaultAsync(t => t.Id == id && t.TenantId == tenantId);
 | 
			
		||||
            WorkItem? task = await _context.WorkItems.AsNoTracking().FirstOrDefaultAsync(t => t.Id == id && t.TenantId == tenantId);
 | 
			
		||||
            if (task != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (task.CompletedWork == 0)
 | 
			
		||||
@ -690,15 +648,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        _context.WorkItems.Remove(task);
 | 
			
		||||
                        await _context.SaveChangesAsync();
 | 
			
		||||
                        _logger.LogInfo("Task with ID {WorkItemId} has been successfully deleted.", task.Id);
 | 
			
		||||
 | 
			
		||||
                        var floorId = task.WorkArea?.FloorId;
 | 
			
		||||
                        var floor = await _context.Floor.Include(f => f.Building).FirstOrDefaultAsync(f => f.Id == floorId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        projectIds.Add(floor?.Building?.ProjectId ?? Guid.Empty);
 | 
			
		||||
 | 
			
		||||
                        var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Infra", ProjectIds = projectIds, Message = $"Task Deleted in Building: {floor?.Building?.Name}, on Floor: {floor?.FloorName}, in Area: {task.WorkArea?.AreaName} by {LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}" };
 | 
			
		||||
                        await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
@ -726,12 +675,8 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
        public async Task<IActionResult> ManageProjectInfra(List<InfraDot> infraDots)
 | 
			
		||||
        {
 | 
			
		||||
            Guid tenantId = GetTenantId();
 | 
			
		||||
            var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
 | 
			
		||||
            var responseData = new InfraVM { };
 | 
			
		||||
            string responseMessage = "";
 | 
			
		||||
            string message = "";
 | 
			
		||||
            List<Guid> projectIds = new List<Guid>();
 | 
			
		||||
            if (infraDots != null)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var item in infraDots)
 | 
			
		||||
@ -749,7 +694,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.building = building;
 | 
			
		||||
                            responseMessage = "Buliding Added Successfully";
 | 
			
		||||
                            message = "Building Added";
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
@ -758,10 +702,8 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.building = building;
 | 
			
		||||
                            responseMessage = "Buliding Updated Successfully";
 | 
			
		||||
                            message = "Building Updated";
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        projectIds.Add(building.ProjectId);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (item.Floor != null)
 | 
			
		||||
                    {
 | 
			
		||||
@ -775,7 +717,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.floor = floor;
 | 
			
		||||
                            responseMessage = "Floor Added Successfully";
 | 
			
		||||
                            message = "Floor Added";
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
@ -784,11 +725,7 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.floor = floor;
 | 
			
		||||
                            responseMessage = "Floor Updated Successfully";
 | 
			
		||||
                            message = "Floor Updated";
 | 
			
		||||
                        }
 | 
			
		||||
                        Building? building = await _context.Buildings.FirstOrDefaultAsync(b => b.Id == floor.BuildingId);
 | 
			
		||||
                        projectIds.Add(building?.ProjectId ?? Guid.Empty);
 | 
			
		||||
                        message = $"{message} in Building: {building?.Name}";
 | 
			
		||||
                    }
 | 
			
		||||
                    if (item.WorkArea != null)
 | 
			
		||||
                    {
 | 
			
		||||
@ -802,7 +739,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.workArea = workArea;
 | 
			
		||||
                            responseMessage = "Work Area Added Successfully";
 | 
			
		||||
                            message = "Work Area Added";
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
@ -811,17 +747,9 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            responseData.workArea = workArea;
 | 
			
		||||
                            responseMessage = "Work Area Updated Successfully";
 | 
			
		||||
                            message = "Work Area Updated";
 | 
			
		||||
                        }
 | 
			
		||||
                        Floor? floor = await _context.Floor.Include(f => f.Building).FirstOrDefaultAsync(f => f.Id == workArea.FloorId);
 | 
			
		||||
                        projectIds.Add(floor?.Building?.ProjectId ?? Guid.Empty);
 | 
			
		||||
                        message = $"{message} in Building: {floor?.Building?.Name}, on Floor: {floor?.FloorName}";
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                message = $"{message} by {LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}";
 | 
			
		||||
                var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Infra", ProjectIds = projectIds, Message = message };
 | 
			
		||||
 | 
			
		||||
                await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
                }
 | 
			
		||||
                return Ok(ApiResponse<object>.SuccessResponse(responseData, responseMessage, 200));
 | 
			
		||||
            }
 | 
			
		||||
            return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Infra Details are not valid.", 400));
 | 
			
		||||
@ -867,15 +795,16 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
            return Ok(ApiResponse<object>.SuccessResponse(projects, "Success.", 200));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [HttpPost("assign-projects/{employeeId}")]
 | 
			
		||||
        public async Task<ActionResult> AssigneProjectsToEmployee([FromBody] List<ProjectsAllocationDto> projectAllocationDtos, [FromRoute] Guid employeeId)
 | 
			
		||||
        {
 | 
			
		||||
            if (projectAllocationDtos != null && employeeId != Guid.Empty)
 | 
			
		||||
            {
 | 
			
		||||
                Guid TenentID = GetTenantId();
 | 
			
		||||
                var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
 | 
			
		||||
                List<object>? result = new List<object>();
 | 
			
		||||
                List<Guid> projectIds = new List<Guid>();
 | 
			
		||||
 | 
			
		||||
                foreach (var projectAllocationDto in projectAllocationDtos)
 | 
			
		||||
                {
 | 
			
		||||
@ -903,8 +832,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                                projectAllocationFromDb.IsActive = false;
 | 
			
		||||
                                _context.Entry(projectAllocationFromDb).Property(e => e.ReAllocationDate).IsModified = true;
 | 
			
		||||
                                _context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
 | 
			
		||||
 | 
			
		||||
                                projectIds.Add(projectAllocation.ProjectId);
 | 
			
		||||
                            }
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
                            var result1 = new
 | 
			
		||||
@ -927,8 +854,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                            _context.ProjectAllocations.Add(projectAllocation);
 | 
			
		||||
                            await _context.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
                            projectIds.Add(projectAllocation.ProjectId);
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -939,9 +864,6 @@ namespace MarcoBMS.Services.Controllers
 | 
			
		||||
                        return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Assign_Project", ProjectIds = projectIds, EmployeeId = employeeId };
 | 
			
		||||
 | 
			
		||||
                await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
 | 
			
		||||
 | 
			
		||||
                return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -1,35 +0,0 @@
 | 
			
		||||
using MarcoBMS.Services.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
using Microsoft.AspNetCore.SignalR;
 | 
			
		||||
 | 
			
		||||
namespace Marco.Pms.Services.Hubs
 | 
			
		||||
{
 | 
			
		||||
    [Authorize]
 | 
			
		||||
    public class MarcoHub : Hub
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILoggingService _logger;
 | 
			
		||||
        public MarcoHub(ILoggingService logger)
 | 
			
		||||
        {
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
        }
 | 
			
		||||
        public async Task SendMessage(string user, string message)
 | 
			
		||||
        {
 | 
			
		||||
            _logger.LogInfo($"User: {user} Message : {message}");
 | 
			
		||||
            await Clients.All.SendAsync("ReceiveMessage", user, message);
 | 
			
		||||
        }
 | 
			
		||||
        public override async Task OnConnectedAsync()
 | 
			
		||||
        {
 | 
			
		||||
            await base.OnConnectedAsync();
 | 
			
		||||
            _logger.LogInfo($"Connected successfully");
 | 
			
		||||
            await Clients.All.SendAsync("Connected successfully");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Optional: override OnDisconnectedAsync
 | 
			
		||||
        public override async Task OnDisconnectedAsync(Exception? exception)
 | 
			
		||||
        {
 | 
			
		||||
            await base.OnDisconnectedAsync(exception);
 | 
			
		||||
            _logger.LogInfo($"DIsonnected successfully");
 | 
			
		||||
            await Clients.All.SendAsync("Disonnected successfully");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -17,7 +17,6 @@
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.12" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.12" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.7" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,6 @@ using Marco.Pms.Model.Authentication;
 | 
			
		||||
using Marco.Pms.Model.Entitlements;
 | 
			
		||||
using Marco.Pms.Model.Utilities;
 | 
			
		||||
using Marco.Pms.Services.Helpers;
 | 
			
		||||
using Marco.Pms.Services.Hubs;
 | 
			
		||||
using Marco.Pms.Services.Service;
 | 
			
		||||
using MarcoBMS.Services.Helpers;
 | 
			
		||||
using MarcoBMS.Services.Middleware;
 | 
			
		||||
@ -60,8 +59,7 @@ builder.Services.AddCors(options =>
 | 
			
		||||
    {
 | 
			
		||||
        policy.AllowAnyOrigin()
 | 
			
		||||
              .AllowAnyMethod()
 | 
			
		||||
              .AllowAnyHeader()
 | 
			
		||||
              .WithExposedHeaders("Authorization");
 | 
			
		||||
              .AllowAnyHeader();
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -163,28 +161,10 @@ if (jwtSettings != null && jwtSettings.Key != null)
 | 
			
		||||
            ValidAudience = jwtSettings.Audience,
 | 
			
		||||
            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Key))
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        options.Events = new JwtBearerEvents
 | 
			
		||||
        {
 | 
			
		||||
            OnMessageReceived = context =>
 | 
			
		||||
            {
 | 
			
		||||
                var accessToken = context.Request.Query["access_token"];
 | 
			
		||||
                var path = context.HttpContext.Request.Path;
 | 
			
		||||
 | 
			
		||||
                // Match your hub route here
 | 
			
		||||
                if (!string.IsNullOrEmpty(accessToken) && path.StartsWithSegments("/hubs/marco"))
 | 
			
		||||
                {
 | 
			
		||||
                    context.Token = accessToken;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return Task.CompletedTask;
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
    builder.Services.AddSingleton(jwtSettings);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
builder.Services.AddSignalR();
 | 
			
		||||
builder.WebHost.ConfigureKestrel(options =>
 | 
			
		||||
{
 | 
			
		||||
    options.AddServerHeader = false; // Disable the "Server" header
 | 
			
		||||
@ -227,7 +207,7 @@ app.UseHttpsRedirection();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
app.UseAuthorization();
 | 
			
		||||
app.MapHub<MarcoHub>("/hubs/marco");
 | 
			
		||||
 | 
			
		||||
app.MapControllers();
 | 
			
		||||
 | 
			
		||||
app.Run();
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@
 | 
			
		||||
        "Title": "Dev"
 | 
			
		||||
    },
 | 
			
		||||
    "ConnectionStrings": {
 | 
			
		||||
        "DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1"
 | 
			
		||||
        "DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMSGuid"
 | 
			
		||||
    },
 | 
			
		||||
    "SmtpSettings": {
 | 
			
		||||
        "SmtpServer": "smtp.gmail.com",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user