diff --git a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs index 4cd2dc6..8526de3 100644 --- a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs +++ b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs @@ -4,7 +4,7 @@ using Marco.Pms.Model.Authentication; using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.Projects; -using MarcoBMS.Utility; +using Marco.Pms.Utility; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; @@ -300,19 +300,19 @@ namespace Marco.Pms.DataAccess.Data Id = 1, Name = "Project", Description = "Project Module", - Key = Guid.NewGuid().ToString() + Key = "b04da7e9-0406-409c-ac7f-b97256e6ea02" }, new Module { Id = 2, Name = "Employee", Description = "Employee Module", - Key = Guid.NewGuid().ToString() + Key = "0971c7fb-6ce1-458a-ae3f-8d3205893637" }, new Module { Id = 3, Name = "Masters", Description = "Masters Module", - Key = Guid.NewGuid().ToString() + Key = "504ec132-e6a9-422f-8f85-050602cfce05" }); diff --git a/Marco.Pms.DataAccess/Initializer/DBInitializer.cs b/Marco.Pms.DataAccess/Initializer/DBInitializer.cs index b3662dc..889e3d7 100644 --- a/Marco.Pms.DataAccess/Initializer/DBInitializer.cs +++ b/Marco.Pms.DataAccess/Initializer/DBInitializer.cs @@ -1,15 +1,10 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Activities; using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; using Marco.Pms.Model.ViewModels; -using MarcoBMS.Utility; +using Marco.Pms.Utility; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; -using System.Text.Json; namespace Marco.Pms.DataAccess.Initializer { @@ -19,14 +14,14 @@ namespace Marco.Pms.DataAccess.Initializer private readonly ApplicationDbContext _db; private readonly UserManager _userManager; private readonly RoleManager _roleManager; - private readonly IUnitOfWork _unitOfWork; + //private readonly IUnitOfWork _unitOfWork; - public DBInitializer(UserManager userManager, RoleManager roleManager, ApplicationDbContext db, IUnitOfWork unitOfWork) + public DBInitializer(UserManager userManager, RoleManager roleManager, ApplicationDbContext db) { _userManager = userManager; _roleManager = roleManager; _db = db; - _unitOfWork = unitOfWork; + //_unitOfWork = unitOfWork; } public void Initialize() diff --git a/Marco.Pms.DataAccess/Marco.Pms.DataAccess.csproj b/Marco.Pms.DataAccess/Marco.Pms.DataAccess.csproj index cb22f94..a6bfd37 100644 --- a/Marco.Pms.DataAccess/Marco.Pms.DataAccess.csproj +++ b/Marco.Pms.DataAccess/Marco.Pms.DataAccess.csproj @@ -7,9 +7,9 @@ - - - + + + @@ -19,26 +19,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.Designer.cs new file mode 100644 index 0000000..21b5489 --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.Designer.cs @@ -0,0 +1,1943 @@ +// +using System; +using Marco.Pms.DataAccess.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250315082651_addEmergencyContactPersonInEmployeeModel")] + partial class addEmergencyContactPersonInEmployeeModel + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + // MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("EmployeeRole") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("TaskAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityId") + .HasColumnType("int"); + + b.Property("CompletedWork") + .HasColumnType("int"); + + b.Property("PlannedWork") + .HasColumnType("int"); + + b.Property("TaskDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ActivityId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("WorkItems"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.Property("WorkItemId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.HasIndex("WorkItemId"); + + b.ToTable("WorkItemMapping"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ApprovedBy") + .HasColumnType("int"); + + b.Property("AttendanceDate") + .HasColumnType("datetime(6)"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("InTime") + .HasColumnType("datetime(6)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("OutTime") + .HasColumnType("datetime(6)"); + + b.Property("ProjectID") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.ToTable("Attendes"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ActivityTime") + .HasColumnType("datetime(6)"); + + b.Property("AttendanceId") + .HasColumnType("int"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("Latitude") + .HasColumnType("longtext"); + + b.Property("Longitude") + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UpdatedBy") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AttendanceId"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.HasIndex("UpdatedBy"); + + b.ToTable("AttendanceLogs"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("IsRevoked") + .HasColumnType("tinyint(1)"); + + b.Property("IsUsed") + .HasColumnType("tinyint(1)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("Token") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AadharNumber") + .HasColumnType("longtext"); + + b.Property("ApplicationUserId") + .HasColumnType("varchar(255)"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CurrentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Email") + .HasColumnType("longtext"); + + b.Property("EmergencyContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmergencyPhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("JobRoleId") + .HasColumnType("int"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MiddleName") + .HasColumnType("longtext"); + + b.Property("PanNumber") + .HasColumnType("longtext"); + + b.Property("PeramnentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("JobRoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartTime") + .HasColumnType("time(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkShifts"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TaskAllocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UnitOfMeasurement") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("TaskAllocationId"); + + b.HasIndex("TenantId"); + + b.ToTable("ActivityMasters"); + + b.HasData( + new + { + Id = 1, + ActivityName = "Core Cutting", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 2, + ActivityName = "Fabrication", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 3, + ActivityName = "Lifting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 4, + ActivityName = "Hanging", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 5, + ActivityName = "Tapping", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 6, + ActivityName = "Welding", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 7, + ActivityName = "Testing", + TenantId = 1, + UnitOfMeasurement = "Area" + }, + new + { + Id = 8, + ActivityName = "Painting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 9, + ActivityName = "Marking Area", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 10, + ActivityName = "Drilling", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 11, + ActivityName = "MS Support Fabrication", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 12, + ActivityName = "MS Support Hanging", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 13, + ActivityName = "Hydrant Volve", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 14, + ActivityName = "Sprinkler Installation", + TenantId = 1, + UnitOfMeasurement = "Number" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("ApplicationRoles"); + + b.HasData( + new + { + Id = new Guid("2c8d0808-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Admin", + TenantId = 1 + }, + new + { + Id = new Guid("62e0918d-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Welder", + TenantId = 1 + }, + new + { + Id = new Guid("68823f1f-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Helper", + TenantId = 1 + }, + new + { + Id = new Guid("6d3a7c72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Site Engineer", + TenantId = 1 + }, + new + { + Id = new Guid("6d3aad72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Project Manager", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("RoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("EmployeeRoleMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ModuleId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ModuleId"); + + b.ToTable("Features"); + + b.HasData( + new + { + Id = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + Description = "Manage Project", + IsActive = true, + ModuleId = 1, + Name = "Manage Project" + }, + new + { + Id = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + Description = "Manage Infra", + IsActive = true, + ModuleId = 1, + Name = "Manage Infra" + }, + new + { + Id = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + Description = "Manage Tasks", + IsActive = true, + ModuleId = 1, + Name = "Manage Tasks" + }, + new + { + Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + Description = "Assign and Update Tasks Progress", + IsActive = true, + ModuleId = 1, + Name = "Assign and Update Tasks Progress" + }, + new + { + Id = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + Description = "Manage Employee", + IsActive = true, + ModuleId = 2, + Name = "Manage Employee" + }, + new + { + Id = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + Description = "Attendance", + IsActive = true, + ModuleId = 2, + Name = "Attendance" + }, + new + { + Id = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + Description = "Global Masters", + IsActive = true, + ModuleId = 3, + Name = "Global Masters" + }, + new + { + Id = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + Description = "Tenant Masters", + IsActive = true, + ModuleId = 3, + Name = "Tenant Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeatureId") + .HasColumnType("char(36)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FeatureId"); + + b.ToTable("FeaturePermissions"); + + b.HasData( + new + { + Id = new Guid("6ea44136-987e-44ba-9e5d-1cf8f5837ebc"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "View Project" + }, + new + { + Id = new Guid("172fc9b6-755b-4f62-ab26-55c34a330614"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Project" + }, + new + { + Id = new Guid("b94802ce-0689-4643-9e1d-11c86950c35b"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Team" + }, + new + { + Id = new Guid("c7b68e33-72f0-474f-bd96-77636427ecc8"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "View Project Infra" + }, + new + { + Id = new Guid("f2aee20a-b754-4537-8166-f9507b44585b"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "Manage Project Infra" + }, + new + { + Id = new Guid("9fcc5f87-25e3-4846-90ac-67a71ab92e3c"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "View Task" + }, + new + { + Id = new Guid("08752f33-3b29-4816-b76b-ea8a968ed3c5"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "Manage Task" + }, + new + { + Id = new Guid("d135a4b0-4f9a-4903-ab9c-4843839ebdee"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Assign Task and Report Progress" + }, + new + { + Id = new Guid("ed99ecd4-1bed-42e1-b7b3-d64c04493823"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Approve Task" + }, + new + { + Id = new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "View Employee" + }, + new + { + Id = new Guid("a97d366a-c2bb-448d-be93-402bd2324566"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Manage Employee" + }, + new + { + Id = new Guid("fbd213e0-0250-46f1-9f5f-4b2a1e6e76a3"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Assign To Project" + }, + new + { + Id = new Guid("915e6bff-65f6-4e3f-aea8-3fd217d3ea9e"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Perform Attendance " + }, + new + { + Id = new Guid("57802c4a-00aa-4a1f-a048-fd2f70dd44b6"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Regularize Attendance" + }, + new + { + Id = new Guid("5ffbafe0-7ab0-48b1-bb50-c1bf76b65f9d"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("588a8824-f924-4955-82d8-fc51956cf323"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "Manage Masters" + }, + new + { + Id = new Guid("cb8ec407-46d4-4467-930c-69127cda6dec"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("6b1a6d97-a951-4de5-9b19-709bac7c4f18"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "Manage Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("JobRoles"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Module", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Key") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Modules"); + + b.HasData( + new + { + Id = 1, + Description = "Project Module", + Key = "b04da7e9-0406-409c-ac7f-b97256e6ea02", + Name = "Project" + }, + new + { + Id = 2, + Description = "Employee Module", + Key = "0971c7fb-6ce1-458a-ae3f-8d3205893637", + Name = "Employee" + }, + new + { + Id = 3, + Description = "Masters Module", + Key = "504ec132-e6a9-422f-8f85-050602cfce05", + Name = "Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.Property("ApplicationRoleId") + .HasColumnType("char(36)"); + + b.Property("FeaturePermissionId") + .HasColumnType("char(36)"); + + b.HasKey("ApplicationRoleId", "FeaturePermissionId"); + + b.HasIndex("FeaturePermissionId"); + + b.ToTable("RolePermissionMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("StatusMasters"); + + b.HasData( + new + { + Id = 1, + Status = "Active", + TenantId = 1 + }, + new + { + Id = 2, + Status = "In Progress", + TenantId = 1 + }, + new + { + Id = 3, + Status = "On Hold", + TenantId = 1 + }, + new + { + Id = 4, + Status = "Completed", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ContactNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DomainName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OnBoardingDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + + b.HasData( + new + { + Id = 1, + ContactName = "Admin", + ContactNumber = "123456789", + Description = "", + DomainName = "www.marcobms.org", + Name = "MarcoBMS", + OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Buildings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("FloorName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("TenantId"); + + b.ToTable("Floor"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EndDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectStatusId") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProjectStatusId"); + + b.HasIndex("TenantId"); + + b.ToTable("Projects"); + + b.HasData( + new + { + Id = 1, + ContactPerson = "Project 1 Contact Person", + Name = "Project 1", + ProjectAddress = "Project 1 Address", + ProjectStatusId = 1, + TenantId = 1 + }, + new + { + Id = 2, + ContactPerson = "Project 2 Contact Person", + Name = "Project 2", + ProjectAddress = "Project 2 Address", + ProjectStatusId = 2, + TenantId = 1 + }, + new + { + Id = 3, + ContactPerson = "Project 3 Contact Person", + Name = "Project 3", + ProjectAddress = "Project 3 Address", + ProjectStatusId = 3, + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("EmployeeRoleId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.ToTable("ProjectAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AreaName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloorId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FloorId"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkAreas"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("varchar(21)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + + b.HasDiscriminator().HasValue("IdentityUser"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("IsRootUser") + .HasColumnType("tinyint(1)"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ApplicationUser"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ActivityMaster", "ActivityMaster") + .WithMany() + .HasForeignKey("ActivityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ActivityMaster"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Activities.WorkItem", "WorkItem") + .WithMany() + .HasForeignKey("WorkItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + + b.Navigation("WorkItem"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Approver") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Approver"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.HasOne("Marco.Pms.Model.AttendanceModule.Attendance", "Attendance") + .WithMany() + .HasForeignKey("AttendanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "UpdatedByEmployee") + .WithMany() + .HasForeignKey("UpdatedBy"); + + b.Navigation("Attendance"); + + b.Navigation("Employee"); + + b.Navigation("Tenant"); + + b.Navigation("UpdatedByEmployee"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId"); + + b.HasOne("Marco.Pms.Model.Entitlements.JobRole", "JobRole") + .WithMany() + .HasForeignKey("JobRoleId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("JobRole"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", null) + .WithMany("AllotedTask") + .HasForeignKey("TaskAllocationId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Role"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Module", "Module") + .WithMany() + .HasForeignKey("ModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Module"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Feature", "Feature") + .WithMany("FeaturePermissions") + .HasForeignKey("FeatureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Feature"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", null) + .WithMany() + .HasForeignKey("ApplicationRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.FeaturePermission", null) + .WithMany() + .HasForeignKey("FeaturePermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.StatusMaster", "ProjectStatus") + .WithMany() + .HasForeignKey("ProjectStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectStatus"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.HasOne("Marco.Pms.Model.Projects.Floor", "Floor") + .WithMany() + .HasForeignKey("FloorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Floor"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Navigation("AllotedTask"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Navigation("FeaturePermissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.cs b/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.cs new file mode 100644 index 0000000..ca20fe3 --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250315082651_addEmergencyContactPersonInEmployeeModel.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + /// + public partial class addEmergencyContactPersonInEmployeeModel : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "EmergencyContactPerson", + table: "Employees", + type: "longtext", + nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "IsActive", + table: "Employees", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EmergencyContactPerson", + table: "Employees"); + + migrationBuilder.DropColumn( + name: "IsActive", + table: "Employees"); + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.Designer.cs new file mode 100644 index 0000000..dfc1d17 --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.Designer.cs @@ -0,0 +1,1943 @@ +// +using System; +using Marco.Pms.DataAccess.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250318053416_addJobRoleIdInProjectAllocation")] + partial class addJobRoleIdInProjectAllocation + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + //MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("EmployeeRole") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("TaskAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityId") + .HasColumnType("int"); + + b.Property("CompletedWork") + .HasColumnType("int"); + + b.Property("PlannedWork") + .HasColumnType("int"); + + b.Property("TaskDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ActivityId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("WorkItems"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.Property("WorkItemId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.HasIndex("WorkItemId"); + + b.ToTable("WorkItemMapping"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ApprovedBy") + .HasColumnType("int"); + + b.Property("AttendanceDate") + .HasColumnType("datetime(6)"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("InTime") + .HasColumnType("datetime(6)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("OutTime") + .HasColumnType("datetime(6)"); + + b.Property("ProjectID") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.ToTable("Attendes"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ActivityTime") + .HasColumnType("datetime(6)"); + + b.Property("AttendanceId") + .HasColumnType("int"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("Latitude") + .HasColumnType("longtext"); + + b.Property("Longitude") + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UpdatedBy") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AttendanceId"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.HasIndex("UpdatedBy"); + + b.ToTable("AttendanceLogs"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("IsRevoked") + .HasColumnType("tinyint(1)"); + + b.Property("IsUsed") + .HasColumnType("tinyint(1)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("Token") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AadharNumber") + .HasColumnType("longtext"); + + b.Property("ApplicationUserId") + .HasColumnType("varchar(255)"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CurrentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Email") + .HasColumnType("longtext"); + + b.Property("EmergencyContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmergencyPhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("JobRoleId") + .HasColumnType("int"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MiddleName") + .HasColumnType("longtext"); + + b.Property("PanNumber") + .HasColumnType("longtext"); + + b.Property("PeramnentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("JobRoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartTime") + .HasColumnType("time(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkShifts"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TaskAllocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UnitOfMeasurement") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("TaskAllocationId"); + + b.HasIndex("TenantId"); + + b.ToTable("ActivityMasters"); + + b.HasData( + new + { + Id = 1, + ActivityName = "Core Cutting", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 2, + ActivityName = "Fabrication", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 3, + ActivityName = "Lifting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 4, + ActivityName = "Hanging", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 5, + ActivityName = "Tapping", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 6, + ActivityName = "Welding", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 7, + ActivityName = "Testing", + TenantId = 1, + UnitOfMeasurement = "Area" + }, + new + { + Id = 8, + ActivityName = "Painting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 9, + ActivityName = "Marking Area", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 10, + ActivityName = "Drilling", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 11, + ActivityName = "MS Support Fabrication", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 12, + ActivityName = "MS Support Hanging", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 13, + ActivityName = "Hydrant Volve", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 14, + ActivityName = "Sprinkler Installation", + TenantId = 1, + UnitOfMeasurement = "Number" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("ApplicationRoles"); + + b.HasData( + new + { + Id = new Guid("2c8d0808-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Admin", + TenantId = 1 + }, + new + { + Id = new Guid("62e0918d-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Welder", + TenantId = 1 + }, + new + { + Id = new Guid("68823f1f-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Helper", + TenantId = 1 + }, + new + { + Id = new Guid("6d3a7c72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Site Engineer", + TenantId = 1 + }, + new + { + Id = new Guid("6d3aad72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Project Manager", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("RoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("EmployeeRoleMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ModuleId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ModuleId"); + + b.ToTable("Features"); + + b.HasData( + new + { + Id = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + Description = "Manage Project", + IsActive = true, + ModuleId = 1, + Name = "Manage Project" + }, + new + { + Id = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + Description = "Manage Infra", + IsActive = true, + ModuleId = 1, + Name = "Manage Infra" + }, + new + { + Id = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + Description = "Manage Tasks", + IsActive = true, + ModuleId = 1, + Name = "Manage Tasks" + }, + new + { + Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + Description = "Assign and Update Tasks Progress", + IsActive = true, + ModuleId = 1, + Name = "Assign and Update Tasks Progress" + }, + new + { + Id = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + Description = "Manage Employee", + IsActive = true, + ModuleId = 2, + Name = "Manage Employee" + }, + new + { + Id = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + Description = "Attendance", + IsActive = true, + ModuleId = 2, + Name = "Attendance" + }, + new + { + Id = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + Description = "Global Masters", + IsActive = true, + ModuleId = 3, + Name = "Global Masters" + }, + new + { + Id = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + Description = "Tenant Masters", + IsActive = true, + ModuleId = 3, + Name = "Tenant Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeatureId") + .HasColumnType("char(36)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FeatureId"); + + b.ToTable("FeaturePermissions"); + + b.HasData( + new + { + Id = new Guid("6ea44136-987e-44ba-9e5d-1cf8f5837ebc"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "View Project" + }, + new + { + Id = new Guid("172fc9b6-755b-4f62-ab26-55c34a330614"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Project" + }, + new + { + Id = new Guid("b94802ce-0689-4643-9e1d-11c86950c35b"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Team" + }, + new + { + Id = new Guid("c7b68e33-72f0-474f-bd96-77636427ecc8"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "View Project Infra" + }, + new + { + Id = new Guid("f2aee20a-b754-4537-8166-f9507b44585b"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "Manage Project Infra" + }, + new + { + Id = new Guid("9fcc5f87-25e3-4846-90ac-67a71ab92e3c"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "View Task" + }, + new + { + Id = new Guid("08752f33-3b29-4816-b76b-ea8a968ed3c5"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "Manage Task" + }, + new + { + Id = new Guid("d135a4b0-4f9a-4903-ab9c-4843839ebdee"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Assign Task and Report Progress" + }, + new + { + Id = new Guid("ed99ecd4-1bed-42e1-b7b3-d64c04493823"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Approve Task" + }, + new + { + Id = new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "View Employee" + }, + new + { + Id = new Guid("a97d366a-c2bb-448d-be93-402bd2324566"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Manage Employee" + }, + new + { + Id = new Guid("fbd213e0-0250-46f1-9f5f-4b2a1e6e76a3"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Assign To Project" + }, + new + { + Id = new Guid("915e6bff-65f6-4e3f-aea8-3fd217d3ea9e"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Perform Attendance " + }, + new + { + Id = new Guid("57802c4a-00aa-4a1f-a048-fd2f70dd44b6"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Regularize Attendance" + }, + new + { + Id = new Guid("5ffbafe0-7ab0-48b1-bb50-c1bf76b65f9d"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("588a8824-f924-4955-82d8-fc51956cf323"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "Manage Masters" + }, + new + { + Id = new Guid("cb8ec407-46d4-4467-930c-69127cda6dec"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("6b1a6d97-a951-4de5-9b19-709bac7c4f18"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "Manage Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("JobRoles"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Module", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Key") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Modules"); + + b.HasData( + new + { + Id = 1, + Description = "Project Module", + Key = "b04da7e9-0406-409c-ac7f-b97256e6ea02", + Name = "Project" + }, + new + { + Id = 2, + Description = "Employee Module", + Key = "0971c7fb-6ce1-458a-ae3f-8d3205893637", + Name = "Employee" + }, + new + { + Id = 3, + Description = "Masters Module", + Key = "504ec132-e6a9-422f-8f85-050602cfce05", + Name = "Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.Property("ApplicationRoleId") + .HasColumnType("char(36)"); + + b.Property("FeaturePermissionId") + .HasColumnType("char(36)"); + + b.HasKey("ApplicationRoleId", "FeaturePermissionId"); + + b.HasIndex("FeaturePermissionId"); + + b.ToTable("RolePermissionMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("StatusMasters"); + + b.HasData( + new + { + Id = 1, + Status = "Active", + TenantId = 1 + }, + new + { + Id = 2, + Status = "In Progress", + TenantId = 1 + }, + new + { + Id = 3, + Status = "On Hold", + TenantId = 1 + }, + new + { + Id = 4, + Status = "Completed", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ContactNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DomainName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OnBoardingDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + + b.HasData( + new + { + Id = 1, + ContactName = "Admin", + ContactNumber = "123456789", + Description = "", + DomainName = "www.marcobms.org", + Name = "MarcoBMS", + OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Buildings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("FloorName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("TenantId"); + + b.ToTable("Floor"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EndDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectStatusId") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProjectStatusId"); + + b.HasIndex("TenantId"); + + b.ToTable("Projects"); + + b.HasData( + new + { + Id = 1, + ContactPerson = "Project 1 Contact Person", + Name = "Project 1", + ProjectAddress = "Project 1 Address", + ProjectStatusId = 1, + TenantId = 1 + }, + new + { + Id = 2, + ContactPerson = "Project 2 Contact Person", + Name = "Project 2", + ProjectAddress = "Project 2 Address", + ProjectStatusId = 2, + TenantId = 1 + }, + new + { + Id = 3, + ContactPerson = "Project 3 Contact Person", + Name = "Project 3", + ProjectAddress = "Project 3 Address", + ProjectStatusId = 3, + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("JobRoleId") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.ToTable("ProjectAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AreaName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloorId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FloorId"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkAreas"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("varchar(21)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + + b.HasDiscriminator().HasValue("IdentityUser"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("IsRootUser") + .HasColumnType("tinyint(1)"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ApplicationUser"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ActivityMaster", "ActivityMaster") + .WithMany() + .HasForeignKey("ActivityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ActivityMaster"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Activities.WorkItem", "WorkItem") + .WithMany() + .HasForeignKey("WorkItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + + b.Navigation("WorkItem"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Approver") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Approver"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.HasOne("Marco.Pms.Model.AttendanceModule.Attendance", "Attendance") + .WithMany() + .HasForeignKey("AttendanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "UpdatedByEmployee") + .WithMany() + .HasForeignKey("UpdatedBy"); + + b.Navigation("Attendance"); + + b.Navigation("Employee"); + + b.Navigation("Tenant"); + + b.Navigation("UpdatedByEmployee"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId"); + + b.HasOne("Marco.Pms.Model.Entitlements.JobRole", "JobRole") + .WithMany() + .HasForeignKey("JobRoleId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("JobRole"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", null) + .WithMany("AllotedTask") + .HasForeignKey("TaskAllocationId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Role"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Module", "Module") + .WithMany() + .HasForeignKey("ModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Module"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Feature", "Feature") + .WithMany("FeaturePermissions") + .HasForeignKey("FeatureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Feature"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", null) + .WithMany() + .HasForeignKey("ApplicationRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.FeaturePermission", null) + .WithMany() + .HasForeignKey("FeaturePermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.StatusMaster", "ProjectStatus") + .WithMany() + .HasForeignKey("ProjectStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectStatus"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.HasOne("Marco.Pms.Model.Projects.Floor", "Floor") + .WithMany() + .HasForeignKey("FloorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Floor"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Navigation("AllotedTask"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Navigation("FeaturePermissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.cs b/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.cs new file mode 100644 index 0000000..60ecfbf --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250318053416_addJobRoleIdInProjectAllocation.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + /// + public partial class addJobRoleIdInProjectAllocation : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EmployeeRoleId", + table: "ProjectAllocations"); + + migrationBuilder.AddColumn( + name: "JobRoleId", + table: "ProjectAllocations", + type: "int", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "JobRoleId", + table: "ProjectAllocations"); + + migrationBuilder.AddColumn( + name: "EmployeeRoleId", + table: "ProjectAllocations", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.Designer.cs new file mode 100644 index 0000000..f8f45ac --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.Designer.cs @@ -0,0 +1,1946 @@ +// +using System; +using Marco.Pms.DataAccess.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20250321010050_addJoiningDateToEmployee")] + partial class addJoiningDateToEmployee + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + //MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("EmployeeRole") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("TaskAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityId") + .HasColumnType("int"); + + b.Property("CompletedWork") + .HasColumnType("int"); + + b.Property("PlannedWork") + .HasColumnType("int"); + + b.Property("TaskDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ActivityId"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.ToTable("WorkItems"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("WorkAreaId") + .HasColumnType("int"); + + b.Property("WorkItemId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("WorkAreaId"); + + b.HasIndex("WorkItemId"); + + b.ToTable("WorkItemMapping"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ApprovedBy") + .HasColumnType("int"); + + b.Property("AttendanceDate") + .HasColumnType("datetime(6)"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("InTime") + .HasColumnType("datetime(6)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("OutTime") + .HasColumnType("datetime(6)"); + + b.Property("ProjectID") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.ToTable("Attendes"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Activity") + .HasColumnType("int"); + + b.Property("ActivityTime") + .HasColumnType("datetime(6)"); + + b.Property("AttendanceId") + .HasColumnType("int"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("Latitude") + .HasColumnType("longtext"); + + b.Property("Longitude") + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UpdatedBy") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AttendanceId"); + + b.HasIndex("EmployeeID"); + + b.HasIndex("TenantId"); + + b.HasIndex("UpdatedBy"); + + b.ToTable("AttendanceLogs"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("IsRevoked") + .HasColumnType("tinyint(1)"); + + b.Property("IsUsed") + .HasColumnType("tinyint(1)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("Token") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AadharNumber") + .HasColumnType("longtext"); + + b.Property("ApplicationUserId") + .HasColumnType("varchar(255)"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CurrentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Email") + .HasColumnType("longtext"); + + b.Property("EmergencyContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmergencyPhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("JobRoleId") + .HasColumnType("int"); + + b.Property("JoiningDate") + .HasColumnType("datetime(6)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MiddleName") + .HasColumnType("longtext"); + + b.Property("PanNumber") + .HasColumnType("longtext"); + + b.Property("PeramnentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Photo") + .HasColumnType("longblob"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("JobRoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartTime") + .HasColumnType("time(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkShifts"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ActivityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TaskAllocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.Property("UnitOfMeasurement") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("TaskAllocationId"); + + b.HasIndex("TenantId"); + + b.ToTable("ActivityMasters"); + + b.HasData( + new + { + Id = 1, + ActivityName = "Core Cutting", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 2, + ActivityName = "Fabrication", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 3, + ActivityName = "Lifting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 4, + ActivityName = "Hanging", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 5, + ActivityName = "Tapping", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 6, + ActivityName = "Welding", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 7, + ActivityName = "Testing", + TenantId = 1, + UnitOfMeasurement = "Area" + }, + new + { + Id = 8, + ActivityName = "Painting", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 9, + ActivityName = "Marking Area", + TenantId = 1, + UnitOfMeasurement = "Meter" + }, + new + { + Id = 10, + ActivityName = "Drilling", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 11, + ActivityName = "MS Support Fabrication", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 12, + ActivityName = "MS Support Hanging", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 13, + ActivityName = "Hydrant Volve", + TenantId = 1, + UnitOfMeasurement = "Number" + }, + new + { + Id = 14, + ActivityName = "Sprinkler Installation", + TenantId = 1, + UnitOfMeasurement = "Number" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("ApplicationRoles"); + + b.HasData( + new + { + Id = new Guid("2c8d0808-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Admin", + TenantId = 1 + }, + new + { + Id = new Guid("62e0918d-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Welder", + TenantId = 1 + }, + new + { + Id = new Guid("68823f1f-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Helper", + TenantId = 1 + }, + new + { + Id = new Guid("6d3a7c72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Site Engineer", + TenantId = 1 + }, + new + { + Id = new Guid("6d3aad72-c421-11ef-9b93-0242ac110002"), + Description = "", + Role = "Project Manager", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("RoleId"); + + b.HasIndex("TenantId"); + + b.ToTable("EmployeeRoleMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("ModuleId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ModuleId"); + + b.ToTable("Features"); + + b.HasData( + new + { + Id = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + Description = "Manage Project", + IsActive = true, + ModuleId = 1, + Name = "Manage Project" + }, + new + { + Id = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + Description = "Manage Infra", + IsActive = true, + ModuleId = 1, + Name = "Manage Infra" + }, + new + { + Id = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + Description = "Manage Tasks", + IsActive = true, + ModuleId = 1, + Name = "Manage Tasks" + }, + new + { + Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + Description = "Assign and Update Tasks Progress", + IsActive = true, + ModuleId = 1, + Name = "Assign and Update Tasks Progress" + }, + new + { + Id = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + Description = "Manage Employee", + IsActive = true, + ModuleId = 2, + Name = "Manage Employee" + }, + new + { + Id = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + Description = "Attendance", + IsActive = true, + ModuleId = 2, + Name = "Attendance" + }, + new + { + Id = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + Description = "Global Masters", + IsActive = true, + ModuleId = 3, + Name = "Global Masters" + }, + new + { + Id = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + Description = "Tenant Masters", + IsActive = true, + ModuleId = 3, + Name = "Tenant Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeatureId") + .HasColumnType("char(36)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("FeatureId"); + + b.ToTable("FeaturePermissions"); + + b.HasData( + new + { + Id = new Guid("6ea44136-987e-44ba-9e5d-1cf8f5837ebc"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "View Project" + }, + new + { + Id = new Guid("172fc9b6-755b-4f62-ab26-55c34a330614"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Project" + }, + new + { + Id = new Guid("b94802ce-0689-4643-9e1d-11c86950c35b"), + Description = "", + FeatureId = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), + IsEnabled = true, + Name = "Manage Team" + }, + new + { + Id = new Guid("c7b68e33-72f0-474f-bd96-77636427ecc8"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "View Project Infra" + }, + new + { + Id = new Guid("f2aee20a-b754-4537-8166-f9507b44585b"), + Description = "", + FeatureId = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), + IsEnabled = true, + Name = "Manage Project Infra" + }, + new + { + Id = new Guid("9fcc5f87-25e3-4846-90ac-67a71ab92e3c"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "View Task" + }, + new + { + Id = new Guid("08752f33-3b29-4816-b76b-ea8a968ed3c5"), + Description = "", + FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), + IsEnabled = true, + Name = "Manage Task" + }, + new + { + Id = new Guid("d135a4b0-4f9a-4903-ab9c-4843839ebdee"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Assign Task and Report Progress" + }, + new + { + Id = new Guid("ed99ecd4-1bed-42e1-b7b3-d64c04493823"), + Description = "", + FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), + IsEnabled = true, + Name = "Approve Task" + }, + new + { + Id = new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "View Employee" + }, + new + { + Id = new Guid("a97d366a-c2bb-448d-be93-402bd2324566"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Manage Employee" + }, + new + { + Id = new Guid("fbd213e0-0250-46f1-9f5f-4b2a1e6e76a3"), + Description = "", + FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), + IsEnabled = true, + Name = "Assign To Project" + }, + new + { + Id = new Guid("915e6bff-65f6-4e3f-aea8-3fd217d3ea9e"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Perform Attendance " + }, + new + { + Id = new Guid("57802c4a-00aa-4a1f-a048-fd2f70dd44b6"), + Description = "", + FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), + IsEnabled = true, + Name = "Regularize Attendance" + }, + new + { + Id = new Guid("5ffbafe0-7ab0-48b1-bb50-c1bf76b65f9d"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("588a8824-f924-4955-82d8-fc51956cf323"), + Description = "", + FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), + IsEnabled = true, + Name = "Manage Masters" + }, + new + { + Id = new Guid("cb8ec407-46d4-4467-930c-69127cda6dec"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "View Masters" + }, + new + { + Id = new Guid("6b1a6d97-a951-4de5-9b19-709bac7c4f18"), + Description = "", + FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), + IsEnabled = true, + Name = "Manage Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("JobRoles"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Module", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Key") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Modules"); + + b.HasData( + new + { + Id = 1, + Description = "Project Module", + Key = "b04da7e9-0406-409c-ac7f-b97256e6ea02", + Name = "Project" + }, + new + { + Id = 2, + Description = "Employee Module", + Key = "0971c7fb-6ce1-458a-ae3f-8d3205893637", + Name = "Employee" + }, + new + { + Id = 3, + Description = "Masters Module", + Key = "504ec132-e6a9-422f-8f85-050602cfce05", + Name = "Masters" + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.Property("ApplicationRoleId") + .HasColumnType("char(36)"); + + b.Property("FeaturePermissionId") + .HasColumnType("char(36)"); + + b.HasKey("ApplicationRoleId", "FeaturePermissionId"); + + b.HasIndex("FeaturePermissionId"); + + b.ToTable("RolePermissionMappings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("StatusMasters"); + + b.HasData( + new + { + Id = 1, + Status = "Active", + TenantId = 1 + }, + new + { + Id = 2, + Status = "In Progress", + TenantId = 1 + }, + new + { + Id = 3, + Status = "On Hold", + TenantId = 1 + }, + new + { + Id = 4, + Status = "Completed", + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ContactNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DomainName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OnBoardingDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + + b.HasData( + new + { + Id = 1, + ContactName = "Admin", + ContactNumber = "123456789", + Description = "", + DomainName = "www.marcobms.org", + Name = "MarcoBMS", + OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Buildings"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BuildingId") + .HasColumnType("int"); + + b.Property("FloorName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("TenantId"); + + b.ToTable("Floor"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ContactPerson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EndDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProjectStatusId") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProjectStatusId"); + + b.HasIndex("TenantId"); + + b.ToTable("Projects"); + + b.HasData( + new + { + Id = 1, + ContactPerson = "Project 1 Contact Person", + Name = "Project 1", + ProjectAddress = "Project 1 Address", + ProjectStatusId = 1, + TenantId = 1 + }, + new + { + Id = 2, + ContactPerson = "Project 2 Contact Person", + Name = "Project 2", + ProjectAddress = "Project 2 Address", + ProjectStatusId = 2, + TenantId = 1 + }, + new + { + Id = 3, + ContactPerson = "Project 3 Contact Person", + Name = "Project 3", + ProjectAddress = "Project 3 Address", + ProjectStatusId = 3, + TenantId = 1 + }); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("EmployeeId") + .HasColumnType("int"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("JobRoleId") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("int"); + + b.Property("ReAllocationDate") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("ProjectId"); + + b.HasIndex("TenantId"); + + b.ToTable("ProjectAllocations"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AreaName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloorId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FloorId"); + + b.HasIndex("TenantId"); + + b.ToTable("WorkAreas"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("varchar(21)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + + b.HasDiscriminator().HasValue("IdentityUser"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("IsRootUser") + .HasColumnType("tinyint(1)"); + + b.Property("Role") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TenantId") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ApplicationUser"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItem", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ActivityMaster", "ActivityMaster") + .WithMany() + .HasForeignKey("ActivityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ActivityMaster"); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.WorkItemMapping", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.WorkArea", "WorkArea") + .WithMany() + .HasForeignKey("WorkAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Activities.WorkItem", "WorkItem") + .WithMany() + .HasForeignKey("WorkItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + + b.Navigation("WorkArea"); + + b.Navigation("WorkItem"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.Attendance", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Approver") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Approver"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.AttendanceModule.AttendanceLog", b => + { + b.HasOne("Marco.Pms.Model.AttendanceModule.Attendance", "Attendance") + .WithMany() + .HasForeignKey("AttendanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Employees.Employee", "UpdatedByEmployee") + .WithMany() + .HasForeignKey("UpdatedBy"); + + b.Navigation("Attendance"); + + b.Navigation("Employee"); + + b.Navigation("Tenant"); + + b.Navigation("UpdatedByEmployee"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Authentication.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.Employee", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId"); + + b.HasOne("Marco.Pms.Model.Entitlements.JobRole", "JobRole") + .WithMany() + .HasForeignKey("JobRoleId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("JobRole"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Employees.WorkShift", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ActivityMaster", b => + { + b.HasOne("Marco.Pms.Model.Activities.TaskAllocation", null) + .WithMany("AllotedTask") + .HasForeignKey("TaskAllocationId"); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.ApplicationRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.EmployeeRoleMapping", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Role"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Module", "Module") + .WithMany() + .HasForeignKey("ModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Module"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.FeaturePermission", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Feature", "Feature") + .WithMany("FeaturePermissions") + .HasForeignKey("FeatureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Feature"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.JobRole", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.RolePermissionMappings", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.ApplicationRole", null) + .WithMany() + .HasForeignKey("ApplicationRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.FeaturePermission", null) + .WithMany() + .HasForeignKey("FeaturePermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.StatusMaster", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Floor", b => + { + b.HasOne("Marco.Pms.Model.Projects.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Building"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.Project", b => + { + b.HasOne("Marco.Pms.Model.Entitlements.StatusMaster", "ProjectStatus") + .WithMany() + .HasForeignKey("ProjectStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectStatus"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.ProjectAllocation", b => + { + b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Projects.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Project"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Projects.WorkArea", b => + { + b.HasOne("Marco.Pms.Model.Projects.Floor", "Floor") + .WithMany() + .HasForeignKey("FloorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Floor"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => + { + b.Navigation("AllotedTask"); + }); + + modelBuilder.Entity("Marco.Pms.Model.Entitlements.Feature", b => + { + b.Navigation("FeaturePermissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.cs b/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.cs new file mode 100644 index 0000000..1bc5bee --- /dev/null +++ b/Marco.Pms.DataAccess/Migrations/20250321010050_addJoiningDateToEmployee.cs @@ -0,0 +1,29 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Marco.Pms.DataAccess.Migrations +{ + /// + public partial class addJoiningDateToEmployee : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "JoiningDate", + table: "Employees", + type: "datetime(6)", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "JoiningDate", + table: "Employees"); + } + } +} diff --git a/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs b/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs index 3d0eafd..0306055 100644 --- a/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs @@ -302,6 +302,10 @@ namespace Marco.Pms.DataAccess.Migrations b.Property("Email") .HasColumnType("longtext"); + b.Property("EmergencyContactPerson") + .IsRequired() + .HasColumnType("longtext"); + b.Property("EmergencyPhoneNumber") .IsRequired() .HasColumnType("longtext"); @@ -314,9 +318,15 @@ namespace Marco.Pms.DataAccess.Migrations .IsRequired() .HasColumnType("longtext"); + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + b.Property("JobRoleId") .HasColumnType("int"); + b.Property("JoiningDate") + .HasColumnType("datetime(6)"); + b.Property("LastName") .IsRequired() .HasColumnType("longtext"); @@ -1193,12 +1203,12 @@ namespace Marco.Pms.DataAccess.Migrations b.Property("EmployeeId") .HasColumnType("int"); - b.Property("EmployeeRoleId") - .HasColumnType("char(36)"); - b.Property("IsActive") .HasColumnType("tinyint(1)"); + b.Property("JobRoleId") + .HasColumnType("int"); + b.Property("ProjectId") .HasColumnType("int"); diff --git a/Marco.Pms.DataAccess/Repository/ActivityMasterRepository.cs b/Marco.Pms.DataAccess/Repository/ActivityMasterRepository.cs deleted file mode 100644 index f78b06b..0000000 --- a/Marco.Pms.DataAccess/Repository/ActivityMasterRepository.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; -using Microsoft.EntityFrameworkCore; -using System.Linq.Expressions; -using System.Linq; - -namespace BulkyBook.DataAccess.Repository -{ - public class ActivityMasterRepository : Repository, IActivityMasterRepository - { - private readonly ApplicationDbContext _context; - public ActivityMasterRepository(ApplicationDbContext context) : base(context) - { - _context = context; - } - - - public void Update(ActivityMaster status) - { - _context.ActivityMasters.Update(status); - } - - public Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.ActivityMasters; - if (filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/ApplicationRolesRepository.cs b/Marco.Pms.DataAccess/Repository/ApplicationRolesRepository.cs deleted file mode 100644 index cb13bc5..0000000 --- a/Marco.Pms.DataAccess/Repository/ApplicationRolesRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; - -namespace BulkyBook.DataAccess.Repository -{ - public class ApplicationRolesRepository : Repository, IApplicationRolesRepository - { - private readonly ApplicationDbContext _db; - public ApplicationRolesRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(ApplicationRole status) - { - _db.ApplicationRoles.Update(status); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/ApplicationUserRepository.cs b/Marco.Pms.DataAccess/Repository/ApplicationUserRepository.cs deleted file mode 100644 index 25b7f3b..0000000 --- a/Marco.Pms.DataAccess/Repository/ApplicationUserRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Marco.Pms.DataAccess.Repository -{ - public class ApplicationUserRepository : Repository, IApplicationUserRepository - { - private readonly ApplicationDbContext _db; - public ApplicationUserRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - } -} diff --git a/Marco.Pms.DataAccess/Repository/AttendenceRepository.cs b/Marco.Pms.DataAccess/Repository/AttendenceRepository.cs deleted file mode 100644 index 2191975..0000000 --- a/Marco.Pms.DataAccess/Repository/AttendenceRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.AttendanceModule; - -namespace BulkyBook.DataAccess.Repository -{ - public class AttendenceRepository : Repository, IAttendenceRepository - { - private readonly ApplicationDbContext _db; - public AttendenceRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(Attendance attendance) - { - _db.Attendes.Update(attendance); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/BuildingRepository.cs b/Marco.Pms.DataAccess/Repository/BuildingRepository.cs deleted file mode 100644 index 9d73d93..0000000 --- a/Marco.Pms.DataAccess/Repository/BuildingRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Projects; - -namespace BulkyBook.DataAccess.Repository -{ - public class BuildingRepository : Repository, IBuildingRepository - { - private readonly ApplicationDbContext _db; - public BuildingRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(Building building) - { - _db.Buildings.Update(building); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/EmployeeRepository.cs b/Marco.Pms.DataAccess/Repository/EmployeeRepository.cs deleted file mode 100644 index 6c4942e..0000000 --- a/Marco.Pms.DataAccess/Repository/EmployeeRepository.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Employees; -using Marco.Pms.Model.Projects; -using Microsoft.EntityFrameworkCore; -using System.Linq.Expressions; -using System.Linq; - -namespace BulkyBook.DataAccess.Repository -{ - public class EmployeeRepository : Repository, IEmployeeRepository - { - private readonly ApplicationDbContext _context; - public EmployeeRepository(ApplicationDbContext db) : base(db) - { - _context = db; - } - - - public void Update(Employee employee) - { - _context.Employees.Update(employee); - } - - public Task> GetAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.Employees; - if (filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/FeaturesRepository.cs b/Marco.Pms.DataAccess/Repository/FeaturesRepository.cs deleted file mode 100644 index 689a880..0000000 --- a/Marco.Pms.DataAccess/Repository/FeaturesRepository.cs +++ /dev/null @@ -1,119 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; -using Microsoft.EntityFrameworkCore; -using System.Linq.Expressions; - -namespace BulkyBook.DataAccess.Repository -{ - public class FeaturesRepository : Repository, IFeatureRepository - { - private readonly ApplicationDbContext _context; - internal DbSet dbSet; - - public FeaturesRepository(ApplicationDbContext db): base(db) - { - _context = db; - this.dbSet = _context.Set(); - - } - - - public void Update(Feature project) - { - _context.Features.Update(project); - } - - - public Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.Features; - if (filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - public Task> GetAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.Features; - - if (filter != null) - { - query.Where(filter); - //var projects1= query2.Where(filter).ToListAsync(); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - - public async Task CreateAsync(Feature projectModel) - { - try - { - await _context.Features.AddAsync(projectModel); - await _context.SaveChangesAsync(); - return projectModel; - } - catch (Exception ex) { throw ex; } - - } - - - - //public async Task UpdateAsync(int id, UpdateFeatureDto projectDto) - //{ - - // var projectModel = await _context.Features.FirstOrDefaultAsync(item => item.Id == id); - - // if (projectModel == null) - // { - // return null; - // } - - // projectModel.ContactPerson = projectDto.ContactPerson; - // projectModel.ProjectAddress = projectDto.ProjectAddress; - // projectModel.Name = projectDto.Name; - // projectModel.EndDate = projectDto.EndDate; - // projectModel.StartDate = projectDto.StartDate; - // //projectModel.TenantId = projectDto.TenantId; - // try - // { - // await _context.SaveChangesAsync(); - // }catch(Exception ex ) - // { - // throw ex; - // } - - // return projectModel; - //} - - - - - } -} diff --git a/Marco.Pms.DataAccess/Repository/FloorRepository.cs b/Marco.Pms.DataAccess/Repository/FloorRepository.cs deleted file mode 100644 index 202fdbb..0000000 --- a/Marco.Pms.DataAccess/Repository/FloorRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Projects; - -namespace BulkyBook.DataAccess.Repository -{ - public class FloorRepository : Repository, IFloorRepository - { - private readonly ApplicationDbContext _db; - public FloorRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(Floor floor) - { - _db.Floor.Update(floor); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IActivityMasterRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IActivityMasterRepository.cs deleted file mode 100644 index 71fe429..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IActivityMasterRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Marco.Pms.Model.Entitlements; -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IActivityMasterRepository : IRepository - { - void Update(ActivityMaster activity); - Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IApplicationRolesRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IApplicationRolesRepository.cs deleted file mode 100644 index df57350..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IApplicationRolesRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Marco.Pms.Model.Entitlements; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IApplicationRolesRepository : IRepository - { - void Update(ApplicationRole role); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IApplicationUserRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IApplicationUserRepository.cs deleted file mode 100644 index 7feb37b..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IApplicationUserRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Marco.Pms.Model.Entitlements; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IApplicationUserRepository : IRepository - { - - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IAttendenceRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IAttendenceRepository.cs deleted file mode 100644 index 6a3c67e..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IAttendenceRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Marco.Pms.Model.AttendanceModule; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - - public interface IAttendenceRepository : IRepository - { - void Update(Attendance employee); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IBuildingRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IBuildingRepository.cs deleted file mode 100644 index aedd6f3..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IBuildingRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Marco.Pms.Model.Projects; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IBuildingRepository : IRepository - { - void Update(Building building); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IEmployeeRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IEmployeeRepository.cs deleted file mode 100644 index ab48ec0..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IEmployeeRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Marco.Pms.Model.Employees; -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - - public interface IEmployeeRepository : IRepository - { - void Update(Employee employee); - Task> GetAsync(Expression>? filter = null, string? includeProperties = null); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IFeatureRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IFeatureRepository.cs deleted file mode 100644 index b35b898..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IFeatureRepository.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Marco.Pms.Model.Dtos.Project; -using Marco.Pms.Model.Entitlements; -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IFeatureRepository : IRepository - { - void Update(Feature Feature); - Task> GetAsync(Expression>? filter = null, string? includeProperties = null); - Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null); - Task CreateAsync(Feature feature); - // Task UpdateAsync(int id, UpdateFeatureDto Feature); - - // Task> GetAsync(int id, string? includeProperties = null); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IFloorRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IFloorRepository.cs deleted file mode 100644 index fcaf538..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IFloorRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Marco.Pms.Model.Projects; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IFloorRepository : IRepository - { - void Update(Floor floor); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IProjectAllocationRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IProjectAllocationRepository.cs deleted file mode 100644 index 6e9f128..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IProjectAllocationRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Marco.Pms.Model.Dtos.Project; -using Marco.Pms.Model.Projects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IProjectAllocationRepository - { - void Update(ProjectAllocation project); - Task> GetAsync(Expression>? filter = null, string? includeProperties = null); - Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null); - Task CreateAsync(ProjectAllocation project); - Task UpdateAsync(int id, ProjectAllocation project); - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IProjectRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IProjectRepository.cs deleted file mode 100644 index ca9c902..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IProjectRepository.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Marco.Pms.Model.Dtos.Project; -using Marco.Pms.Model.Projects; -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IProjectRepository : IRepository - { - void Update(Project project); - Task> GetAsync(Expression>? filter = null, string? includeProperties = null); - Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null); - Task CreateAsync(Project project); - Task UpdateAsync(int id, UpdateProjectDto project); - - // Task> GetAsync(int id, string? includeProperties = null); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IRepository.cs deleted file mode 100644 index 073b6f0..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IRepository.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IRepository where T : class - { - // T - Category - IEnumerable GetAll(Expression>? filter, string? includeProperties = null); - //T GetFirstOrDefault(); - T Get(Expression> filter, string? includeProperties = null, bool tracked = false); - Task GetAsync(Expression> filter, bool tracked = false, params Expression>[] includeProperties); - void Add(T entity); - void Remove(T entity); - void RemoveRange(IEnumerable entity); - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IStatusRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IStatusRepository.cs deleted file mode 100644 index f86139b..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IStatusRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IStatusRepository : IRepository - { - void Update(StatusMaster status); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/ITaskAllocationRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/ITaskAllocationRepository.cs deleted file mode 100644 index 00b07b1..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/ITaskAllocationRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Marco.Pms.Model.Activities; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - - public interface ITaskAllocationRepository : IRepository - { - void Update(TaskAllocation employeeAllocation); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IUnitOfWork.cs b/Marco.Pms.DataAccess/Repository/IRepository/IUnitOfWork.cs deleted file mode 100644 index 0994eba..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IUnitOfWork.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IUnitOfWork - { - IApplicationUserRepository ApplicationUser { get; } - - IEmployeeRepository Employee { get; } - ITaskAllocationRepository EmployeeAllocation - { get; } - IProjectRepository Project { get; } - IProjectAllocationRepository ProjectAllocation { get; } - - IBuildingRepository Building { get; } - IFloorRepository Floor { get; } - - IWorkAreaRepository WorkArea { get; } - IWorkItemRepository WorkItem { get; } - IWorkItemMappingReposiotry WorkItemMapping { get;} - - - IAttendenceRepository Attendence { get; } - IStatusRepository StatusMaster { get; } - IActivityMasterRepository ActivityMaster { get; } - IApplicationRolesRepository EmployeeRoles { get; } - IFeatureRepository Features { get; } - void Save(); - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IWorkAreaRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IWorkAreaRepository.cs deleted file mode 100644 index 7ae68d6..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IWorkAreaRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Marco.Pms.Model.Projects; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IWorkAreaRepository : IRepository - { - void Update(WorkArea workArea); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemMappingReposiotry.cs b/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemMappingReposiotry.cs deleted file mode 100644 index c6f0cbc..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemMappingReposiotry.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Marco.Pms.Model.Activities; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IWorkItemMappingReposiotry : IRepository - { - void Update(WorkItemMapping mapping); - } -} diff --git a/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemRepository.cs b/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemRepository.cs deleted file mode 100644 index 0ee149e..0000000 --- a/Marco.Pms.DataAccess/Repository/IRepository/IWorkItemRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Marco.Pms.Model.Activities; -using Marco.Pms.Model.Projects; - -namespace Marco.Pms.DataAccess.Repository.IRepository -{ - public interface IWorkItemRepository : IRepository - { - void Update(WorkItem workItem); - } - -} diff --git a/Marco.Pms.DataAccess/Repository/ProjectAllocationRepository.cs b/Marco.Pms.DataAccess/Repository/ProjectAllocationRepository.cs deleted file mode 100644 index ca356bd..0000000 --- a/Marco.Pms.DataAccess/Repository/ProjectAllocationRepository.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Dtos.Project; -using Marco.Pms.Model.Projects; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; - -namespace Marco.Pms.DataAccess.Repository -{ - public class ProjectAllocationRepository : Repository, IProjectAllocationRepository - { - private readonly ApplicationDbContext _context; - internal DbSet dbSet; - - public ProjectAllocationRepository(ApplicationDbContext db) : base(db) - { - _context = db; - this.dbSet = _context.Set(); - } - - - public void Update(ProjectAllocation project) - { - _context.ProjectAllocations.Update(project); - } - - public async Task CreateAsync(ProjectAllocation project) - { - await _context.ProjectAllocations.AddAsync(project); - await _context.SaveChangesAsync(); - return project; - } - - public Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null) - { - throw new NotImplementedException(); - } - - public Task> GetAsync(Expression>? filter = null, string? includeProperties = null) - { - IQueryable query = _context.ProjectAllocations; - if (filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToListAsync(); - } - - - public async Task UpdateAsync(int id, ProjectAllocation project) - { - var allocation = await _context.ProjectAllocations.FirstOrDefaultAsync(item => item.Id == id); - - if (allocation == null) - { - return null; - } - - allocation.ProjectId = project.ProjectId; - allocation.EmployeeId = project.EmployeeId; - allocation.AllocationDate = project.AllocationDate; - allocation.ReAllocationDate = project.ReAllocationDate; - allocation.TenantId = project.TenantId; - - - _context.ProjectAllocations.Update(allocation); - await _context.SaveChangesAsync(); - - return allocation; - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/ProjectRepository.cs b/Marco.Pms.DataAccess/Repository/ProjectRepository.cs deleted file mode 100644 index bed7d6c..0000000 --- a/Marco.Pms.DataAccess/Repository/ProjectRepository.cs +++ /dev/null @@ -1,146 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Dtos.Project; -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; -using Microsoft.EntityFrameworkCore; -using System.Linq; -using System.Linq.Expressions; -using System.Xml; -using System.Xml.Linq; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; - -namespace BulkyBook.DataAccess.Repository -{ - public class ProjectRepository : Repository, IProjectRepository - { - private readonly ApplicationDbContext _context; - internal DbSet dbSet; - - public ProjectRepository(ApplicationDbContext db) : base(db) - { - _context = db; - this.dbSet = _context.Set(); - - } - - - public void Update(Project project) - { - _context.Projects.Update(project); - } - - - public Task> GetAllAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.Projects; - if (filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - public Task> GetAsync(Expression>? filter = null, string? includeProperties = null) - { - - IQueryable query = _context.Projects; - //IQueryable query2 = _context.Projects; - - Expression> filter1 = x => x.Id == 2; - if (filter != null) - { - query.Where(filter); - //var projects1= query2.Where(filter).ToListAsync(); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - - return query.ToListAsync(); - - - // return await _context.Projects.ToListAsync(); ; - } - - public async Task CreateAsync(Project projectModel) - { - try - { - await _context.Projects.AddAsync(projectModel); - await _context.SaveChangesAsync(); - return projectModel; - } - catch (Exception ex) { throw ex; } - - } - - public async Task UpdateAsync(int id, UpdateProjectDto projectDto) - { - - var projectModel = await _context.Projects.FirstOrDefaultAsync(item => item.Id == id); - - if (projectModel == null) - { - return null; - } - - projectModel.ContactPerson = projectDto.ContactPerson; - projectModel.ProjectAddress = projectDto.ProjectAddress; - projectModel.Name = projectDto.Name; - projectModel.EndDate = projectDto.EndDate; - projectModel.StartDate = projectDto.StartDate; - //projectModel.TenantId = projectDto.TenantId; - try - { - await _context.SaveChangesAsync(); - }catch(Exception ex ) - { - throw ex; - } - - return projectModel; - } - - - - //public Task> GetAsync(int id, string? includeProperties = null) - //{ - - // IQueryable query = _context.Projects; - // query.Where(c=>c.Id == id); - // // Task project = _context.Projects.Where(c=>c.Id == id).SingleOrDefaultAsync(); - // //if (filter != null) - // //{ - // // query.Where(filter); - // //} - // //if (!string.IsNullOrEmpty(includeProperties)) - // //{ - // // foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - // // { - // // query = query.Include(includeProp); - // // } - // //} - // return query.ToListAsync(); - - - // // return await _context.Projects.ToListAsync(); ; - //} - - } -} diff --git a/Marco.Pms.DataAccess/Repository/Repository.cs b/Marco.Pms.DataAccess/Repository/Repository.cs deleted file mode 100644 index 7b69363..0000000 --- a/Marco.Pms.DataAccess/Repository/Repository.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; -using Microsoft.EntityFrameworkCore; -using System.Linq.Expressions; - -namespace Marco.Pms.DataAccess.Repository -{ - public class Repository : IRepository where T : class - { - private readonly ApplicationDbContext _context; - internal DbSet dbSet; - public Repository(ApplicationDbContext context) - { - _context = context; - this.dbSet = _context.Set(); - - //_db.Products.Include(u => u.Category); - } - public void Add(T entity) - { - dbSet.Add(entity); - } - - public T Get(Expression> filter, string? includeProperties = null, bool tracked = false) - { - IQueryable query = dbSet; - if (tracked) - { - query = query.Where(filter); - } - else - { - query = query.AsNoTracking().Where(filter); - } - - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - - return query.FirstOrDefault(); - - } - - public async Task GetAsync(Expression> filter, bool tracked = false, params Expression>[] includeProperties) - { - IQueryable query = dbSet; - if (tracked) - { - query = query.Where(filter); - } - else - { - query = query.AsNoTracking().Where(filter); - } - - if (includeProperties != null) - { - foreach (var includeProp in includeProperties) - { - query = query.Include(includeProp); - } - } - - return await query.SingleOrDefaultAsync(); - - } - - public IEnumerable GetAll(Expression>? filter = null, string? includeProperties = null) - { - IQueryable query = dbSet; - if(filter != null) - { - query.Where(filter); - } - if (!string.IsNullOrEmpty(includeProperties)) - { - foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - query = query.Include(includeProp); - } - } - return query.ToList(); - - } - - public void Remove(T entity) - { - dbSet.Remove(entity); - } - - public void RemoveRange(IEnumerable entity) - { - dbSet.RemoveRange(entity); - } - - - } -} diff --git a/Marco.Pms.DataAccess/Repository/StatusRepository.cs b/Marco.Pms.DataAccess/Repository/StatusRepository.cs deleted file mode 100644 index 2d9c92d..0000000 --- a/Marco.Pms.DataAccess/Repository/StatusRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; -using Marco.Pms.Model.Projects; - -namespace BulkyBook.DataAccess.Repository -{ - public class StatusRepository : Repository, IStatusRepository - { - private readonly ApplicationDbContext _db; - public StatusRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(StatusMaster status) - { - _db.StatusMasters.Update(status); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/TaskAllocationRepository.cs b/Marco.Pms.DataAccess/Repository/TaskAllocationRepository.cs deleted file mode 100644 index 13521f4..0000000 --- a/Marco.Pms.DataAccess/Repository/TaskAllocationRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Activities; - -namespace BulkyBook.DataAccess.Repository -{ - public class TaskAllocationRepository : Repository, ITaskAllocationRepository - { - private readonly ApplicationDbContext _db; - public TaskAllocationRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - public void Update(TaskAllocation employeeAllocation) - { - _db.TaskAllocations.Update(employeeAllocation); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/UnitOfWork.cs b/Marco.Pms.DataAccess/Repository/UnitOfWork.cs deleted file mode 100644 index bac22da..0000000 --- a/Marco.Pms.DataAccess/Repository/UnitOfWork.cs +++ /dev/null @@ -1,64 +0,0 @@ -using BulkyBook.DataAccess.Repository; -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; - -namespace Marco.Pms.DataAccess.Repository -{ - public class UnitOfWork : IUnitOfWork - { - private readonly ApplicationDbContext _db; - - public IApplicationUserRepository ApplicationUser { get; private set; } - - public IEmployeeRepository Employee { get; private set; } - public ITaskAllocationRepository EmployeeAllocation { get; private set; } - - public IProjectRepository Project { get; private set; } - public IProjectAllocationRepository ProjectAllocation { get; private set; } - - public IBuildingRepository Building { get; private set; } - public IFloorRepository Floor { get; private set; } - public IAttendenceRepository Attendence { get; private set; } - - public IWorkAreaRepository WorkArea { get; private set; } - - public IWorkItemRepository WorkItem { get; private set; } - - public IWorkItemMappingReposiotry WorkItemMapping { get; private set; } - - public IStatusRepository StatusMaster { get; private set; } - public IActivityMasterRepository ActivityMaster { get; private set; } - public IApplicationRolesRepository EmployeeRoles { get; private set; } - public IFeatureRepository Features { get; private set; } - - - public UnitOfWork(ApplicationDbContext db) - { - _db = db; - Employee = new EmployeeRepository(_db); - Project = new ProjectRepository(_db); - ProjectAllocation = new ProjectAllocationRepository(_db); - - Building = new BuildingRepository(_db); - Floor = new FloorRepository(_db); - WorkArea = new WorkAreaRepository(_db); - WorkItem = new WorkItemRepository(_db); - WorkItemMapping = new WorkItemMappingReporitury(_db); - - ApplicationUser = new ApplicationUserRepository(_db); - Attendence = new AttendenceRepository(_db); - EmployeeAllocation = new TaskAllocationRepository(_db); - - StatusMaster = new StatusRepository(_db); - ActivityMaster = new ActivityMasterRepository(_db); - EmployeeRoles = new ApplicationRolesRepository(_db); - Features = new FeaturesRepository(_db); - - } - - public void Save() - { - _db.SaveChanges(); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/WorkAreaRepository.cs b/Marco.Pms.DataAccess/Repository/WorkAreaRepository.cs deleted file mode 100644 index 0bdeb25..0000000 --- a/Marco.Pms.DataAccess/Repository/WorkAreaRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Projects; - -namespace BulkyBook.DataAccess.Repository -{ - public class WorkAreaRepository : Repository, IWorkAreaRepository - { - private readonly ApplicationDbContext _db; - public WorkAreaRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(WorkArea workArea) - { - _db.WorkAreas.Update(workArea); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/WorkItemMappingReporitury.cs b/Marco.Pms.DataAccess/Repository/WorkItemMappingReporitury.cs deleted file mode 100644 index f70914e..0000000 --- a/Marco.Pms.DataAccess/Repository/WorkItemMappingReporitury.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Activities; - -namespace BulkyBook.DataAccess.Repository -{ - public class WorkItemMappingReporitury : Repository, IWorkItemMappingReposiotry - { - private readonly ApplicationDbContext _db; - public WorkItemMappingReporitury(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(WorkItemMapping workItem) - { - _db.WorkItemMapping.Update(workItem); - } - } -} diff --git a/Marco.Pms.DataAccess/Repository/WorkItemRepository.cs b/Marco.Pms.DataAccess/Repository/WorkItemRepository.cs deleted file mode 100644 index 065ed89..0000000 --- a/Marco.Pms.DataAccess/Repository/WorkItemRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Activities; - -namespace BulkyBook.DataAccess.Repository -{ - public class WorkItemRepository : Repository, IWorkItemRepository - { - private readonly ApplicationDbContext _db; - public WorkItemRepository(ApplicationDbContext db) : base(db) - { - _db = db; - } - - - public void Update(WorkItem workItem) - { - _db.WorkItems.Update(workItem); - } - } -} diff --git a/Marco.Pms.Model/Activities/TaskAllocation.cs b/Marco.Pms.Model/Activities/TaskAllocation.cs index 43e5d65..6c99950 100644 --- a/Marco.Pms.Model/Activities/TaskAllocation.cs +++ b/Marco.Pms.Model/Activities/TaskAllocation.cs @@ -1,7 +1,7 @@ using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.Projects; -using MarcoBMS.Utility; +using Marco.Pms.Utility; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using System.ComponentModel; using System.ComponentModel.DataAnnotations.Schema; diff --git a/Marco.Pms.Model/Dtos/Employees/CreateUserDto.cs b/Marco.Pms.Model/Dtos/Employees/CreateUserDto.cs index 5f295c0..7592fbd 100644 --- a/Marco.Pms.Model/Dtos/Employees/CreateUserDto.cs +++ b/Marco.Pms.Model/Dtos/Employees/CreateUserDto.cs @@ -30,8 +30,8 @@ namespace Marco.Pms.Model.Dtos.Employees public string? PanNumber { get; set; } - public IFormFile? Photo { get; set; } // To store the captured photo - public List? Documents { get; set; } + //public IFormFile? Photo { get; set; } // To store the captured photo + //public List? Documents { get; set; } public string JobRoleId { get; set; } diff --git a/Marco.Pms.Model/Dtos/Project/ProjectAllocationDot.cs b/Marco.Pms.Model/Dtos/Project/ProjectAllocationDot.cs index 08690ea..6d5604e 100644 --- a/Marco.Pms.Model/Dtos/Project/ProjectAllocationDot.cs +++ b/Marco.Pms.Model/Dtos/Project/ProjectAllocationDot.cs @@ -3,7 +3,7 @@ public class ProjectAllocationDot { public int EmpID { get; set; } - public Guid RoleID { get; set; } + public int JobRoleId { get; set; } public int ProjectId { get; set; } public bool Status { get; set; } diff --git a/Marco.Pms.Model/Dtos/ResetPasswordDto.cs b/Marco.Pms.Model/Dtos/ResetPasswordDto.cs index 5ad8573..971da66 100644 --- a/Marco.Pms.Model/Dtos/ResetPasswordDto.cs +++ b/Marco.Pms.Model/Dtos/ResetPasswordDto.cs @@ -14,8 +14,5 @@ namespace Marco.Pms.Model.Dtos [Required] [MinLength(6)] public string NewPassword { get; set; } - - [Compare("NewPassword", ErrorMessage = "Passwords do not match.")] - public string ConfirmPassword { get; set; } } } diff --git a/Marco.Pms.Model/Dtos/Util/EmailDot.cs b/Marco.Pms.Model/Dtos/Util/EmailDot.cs new file mode 100644 index 0000000..a09c921 --- /dev/null +++ b/Marco.Pms.Model/Dtos/Util/EmailDot.cs @@ -0,0 +1,11 @@ +namespace Marco.Pms.Model.Dtos.Util +{ + public class EmailDot + { + public string ToEmail { get; set; } + public string FromEmail { get; set; } + public string MailBody { get; set; } + public string MailSubject { get; set; } + + } +} diff --git a/Marco.Pms.Model/Employees/Employee.cs b/Marco.Pms.Model/Employees/Employee.cs index 303c995..7c8136b 100644 --- a/Marco.Pms.Model/Employees/Employee.cs +++ b/Marco.Pms.Model/Employees/Employee.cs @@ -15,11 +15,15 @@ namespace Marco.Pms.Model.Employees public string Gender { get; set; } public DateTime? BirthDate { get; set; } + public DateTime? JoiningDate { get; set; } + public string PeramnentAddress { get; set; } public string CurrentAddress { get; set; } public string PhoneNumber { get; set; } public string EmergencyPhoneNumber { get; set; } + public string EmergencyContactPerson { get; set; } + public string? AadharNumber { get; set; } @@ -34,6 +38,8 @@ namespace Marco.Pms.Model.Employees [DisplayName("TenantId")] public int TenantId { get; set; } + public bool IsActive { get; set; } = true; + [ValidateNever] [ForeignKey(nameof(TenantId))] public Tenant Tenant { get; set; } diff --git a/Marco.Pms.Model/Mapper/ApplicationRoleMapper.cs b/Marco.Pms.Model/Mapper/ApplicationRoleMapper.cs index 8468e3d..e2074ce 100644 --- a/Marco.Pms.Model/Mapper/ApplicationRoleMapper.cs +++ b/Marco.Pms.Model/Mapper/ApplicationRoleMapper.cs @@ -23,7 +23,6 @@ namespace Marco.Pms.Model.Mapper Id = new Guid(), Role = model.Role, Description = model.Description, - //FeaturePermissions = model.FeaturesPermission, TenantId = TenantId, }; } diff --git a/Marco.Pms.Model/Mapper/EmployeeMapper.cs b/Marco.Pms.Model/Mapper/EmployeeMapper.cs new file mode 100644 index 0000000..9290662 --- /dev/null +++ b/Marco.Pms.Model/Mapper/EmployeeMapper.cs @@ -0,0 +1,35 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.ViewModels.Employee; + +namespace Marco.Pms.Model.Mapper +{ + public static class EmployeeMapper + { + public static EmployeeVM ToEmployeeVMFromEmployee(this Employee model) + { + return new EmployeeVM + { + Id = model.Id, + FirstName = model.FirstName, + LastName = model.LastName, + MiddleName = model.MiddleName, + Email = model.Email, + CurrentAddress = model.CurrentAddress, + BirthDate = model.BirthDate, + AadharNumber = model.AadharNumber, + ApplicationUserId = model.ApplicationUserId, + EmergencyPhoneNumber = model.EmergencyPhoneNumber, + EmergencyContactPerson = model.EmergencyContactPerson, + Gender = model.Gender, + JobRole = (model.JobRole != null ? model.JobRole.Name : null), + JobRoleId = model.JobRoleId, + PanNumber = model.PanNumber, + PeramnentAddress = model.PeramnentAddress, + PhoneNumber = model.PhoneNumber, + Photo = model.Photo, + IsActive = model.IsActive, + JoiningDate = model.JoiningDate + }; + } + } +} diff --git a/Marco.Pms.Model/Mapper/ProjectMapper.cs b/Marco.Pms.Model/Mapper/ProjectMapper.cs index f48e026..6801a11 100644 --- a/Marco.Pms.Model/Mapper/ProjectMapper.cs +++ b/Marco.Pms.Model/Mapper/ProjectMapper.cs @@ -34,6 +34,19 @@ namespace Marco.Pms.Model.Mapper }; } + public static Project ToProjectFromUpdateProjectDto(this UpdateProjectDto projectModel, int TenantId) + { + return new Project + { + ContactPerson = projectModel.ContactPerson, + ProjectAddress = projectModel.ProjectAddress, + Name = projectModel.Name, + EndDate = projectModel.EndDate, + StartDate = projectModel.StartDate, + TenantId = TenantId, + ProjectStatusId = projectModel.ProjectStatusId + }; + } public static ProjectAllocation ToProjectAllocationFromProjectAllocationDto(this ProjectAllocationDot model, int TenantId) { @@ -41,7 +54,7 @@ namespace Marco.Pms.Model.Mapper { AllocationDate = DateTime.Now, EmployeeId = model.EmpID, - EmployeeRoleId = model.RoleID, + JobRoleId = model.JobRoleId, TenantId = TenantId, ProjectId = model.ProjectId }; diff --git a/Marco.Pms.Model/Projects/ProjectAllocation.cs b/Marco.Pms.Model/Projects/ProjectAllocation.cs index d7ef982..7752c1c 100644 --- a/Marco.Pms.Model/Projects/ProjectAllocation.cs +++ b/Marco.Pms.Model/Projects/ProjectAllocation.cs @@ -14,7 +14,7 @@ namespace Marco.Pms.Model.Projects [ValidateNever] public Employee Employee { get; set; } - public Guid? EmployeeRoleId { get; set; } + public int? JobRoleId { get; set; } //[ForeignKey("EmployeeRoleId")] //[ValidateNever] //public EmployeeRole EmployeeRole { get; set; } diff --git a/Marco.Pms.Model/ViewModels/Employee/EmployeeProfile.cs b/Marco.Pms.Model/ViewModels/Employee/EmployeeProfile.cs new file mode 100644 index 0000000..33e17b5 --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Employee/EmployeeProfile.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Marco.Pms.Model.ViewModels.Employee +{ + public class EmployeeProfile + { + public EmployeeVM EmployeeInfo { get; set; } + public string[] Projects { get; set; } + public string[] FeaturePermissions { get; set; } + } +} diff --git a/Marco.Pms.Model/ViewModels/Employee/EmployeeVM.cs b/Marco.Pms.Model/ViewModels/Employee/EmployeeVM.cs new file mode 100644 index 0000000..0700a46 --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Employee/EmployeeVM.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Marco.Pms.Model.ViewModels.Employee +{ + public class EmployeeVM + { + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string? MiddleName { get; set; } + public string? Email { get; set; } + + public string Gender { get; set; } + public DateTime? BirthDate { get; set; } + public DateTime? JoiningDate { get; set; } + public string PeramnentAddress { get; set; } + public string CurrentAddress { get; set; } + public string PhoneNumber { get; set; } + + public string EmergencyPhoneNumber { get; set; } + public string EmergencyContactPerson { get; set; } + + public string? AadharNumber { get; set; } + + public bool IsActive { get; set; } = true; + public string? PanNumber { get; set; } + + public byte[]? Photo { get; set; } // To store the captured photo + + public string? ApplicationUserId { get; set; } + + public int? JobRoleId { get; set; } + public string JobRole { get; set; } + + } +} diff --git a/Marco.Pms.Services/Controllers/ActivityController.cs b/Marco.Pms.Services/Controllers/ActivityController.cs index 4acfb73..cab04af 100644 --- a/Marco.Pms.Services/Controllers/ActivityController.cs +++ b/Marco.Pms.Services/Controllers/ActivityController.cs @@ -1,14 +1,10 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; -using MarcoBMS.Services.Service; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -namespace MarcoBMS.Services.Controllers +namespace ModelServices.Controllers { [Route("api/[controller]")] @@ -18,17 +14,13 @@ namespace MarcoBMS.Services.Controllers { private readonly ApplicationDbContext _context; private ApplicationUser _applicationUser; - private readonly IEmployeeRepository _empRepo; private readonly UserManager _userManager; - private readonly IEmailSender _emailSender; - public ActivityController(UserManager userManager, IEmailSender emailSender, IEmployeeRepository empRepo, ApplicationDbContext context) + public ActivityController(UserManager userManager, ApplicationDbContext context) { _context = context; - _empRepo = empRepo; _userManager = userManager; - _emailSender = emailSender; } //[HttpPost("checkin")] diff --git a/Marco.Pms.Services/Controllers/AttendanceController.cs b/Marco.Pms.Services/Controllers/AttendanceController.cs index c462f44..37b3471 100644 --- a/Marco.Pms.Services/Controllers/AttendanceController.cs +++ b/Marco.Pms.Services/Controllers/AttendanceController.cs @@ -1,5 +1,4 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; using Marco.Pms.Model.AttendanceModule; using Marco.Pms.Model.Dtos.Attendance; using Marco.Pms.Model.Employees; @@ -7,8 +6,6 @@ using Marco.Pms.Model.Projects; using Marco.Pms.Model.Utilities; using Marco.Pms.Model.ViewModels.Attendance; using MarcoBMS.Services.Helpers; -using MarcoBMS.Services.Service; -using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis; using Microsoft.EntityFrameworkCore; @@ -20,34 +17,26 @@ namespace MarcoBMS.Services.Controllers [Route("api/[controller]")] public class AttendanceController : ControllerBase { - private readonly IUnitOfWork _unitOfWork; private readonly ApplicationDbContext _context; - private readonly UserManager _userManager; - private readonly IEmailSender _emailSender; - private readonly IAttendenceRepository _attendenceRepository; private readonly EmployeeHelper _employeeHelper; - private readonly ProjectHelper _projectHelper; + private readonly ProjectsHelper _projectsHelper; + private readonly UserHelper _userHelper; - - - - public AttendanceController(UserManager userManager, IEmailSender emailSender, IEmployeeRepository empRepo, - IUnitOfWork unitOfWork, ApplicationDbContext context, IAttendenceRepository attendenceRepository, EmployeeHelper employeeHelper, ProjectHelper projectHelper) + public AttendanceController( + ApplicationDbContext context, EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper) { - _unitOfWork = unitOfWork; _context = context; - _userManager = userManager; - _emailSender = emailSender; - _attendenceRepository = attendenceRepository; _employeeHelper = employeeHelper; - _projectHelper = projectHelper; + _projectsHelper = projectsHelper; + _userHelper = userHelper; } private int GetTenantId() { - var tenant = User.FindFirst("TenantId")?.Value; - return (tenant != null ? Convert.ToInt32(tenant) : 1); + return _userHelper.GetTenantId(); + //var tenant = User.FindFirst("TenantId")?.Value; + //return (tenant != null ? Convert.ToInt32(tenant) : 1); } private int GetUserId() { @@ -91,18 +80,25 @@ namespace MarcoBMS.Services.Controllers /// ProjectID /// YYYY-MM-dd /// - [HttpGet("project/team")] + [HttpGet("project/log")] - public async Task EmployeeAttendanceByProject([FromQuery] int projectId, [FromQuery] string? date = null) + public async Task EmployeeAttendanceByDateRange([FromQuery] int projectId, [FromQuery] string? dateFrom = null, [FromQuery] string? dateTo = null) { int TenantId = GetUserId(); - DateTime forDate = new DateTime(); + DateTime fromDate = new DateTime(); + DateTime toDate = new DateTime(); - if (date != null && DateTime.TryParse(date, out forDate) == false) + if (dateFrom != null && DateTime.TryParse(dateFrom, out fromDate) == false) { - return StatusCode(400, ApiResponse.SuccessResponse(date, "Invalid Date", 400));// new { error = ex.Message }); + return StatusCode(400, ApiResponse.SuccessResponse(dateFrom, "Invalid Date", 400));// new { error = ex.Message }); } + if (dateTo != null && DateTime.TryParse(dateTo, out toDate) == false) + { + return StatusCode(400, ApiResponse.SuccessResponse(dateTo, "Invalid Date", 400));// new { error = ex.Message }); + + } + if (projectId <= 0) { return BadRequest("Project ID is required and must be greater than zero."); @@ -111,12 +107,14 @@ namespace MarcoBMS.Services.Controllers var result = new List(); Attendance attendance = null; - if (date == null) forDate = DateTime.UtcNow.Date; - - List lstAttendance = await _context.Attendes.Where(c => c.ProjectID == projectId && c.AttendanceDate.Date == forDate && c.TenantId == TenantId).ToListAsync(); + if (dateFrom == null) fromDate = DateTime.UtcNow.Date; + if (dateTo == null && dateFrom != null) toDate = fromDate.AddDays(-1); - List projectteam = await _projectHelper.GetTeamByProject(TenantId, projectId, true); + List lstAttendance = await _context.Attendes.Where(c => c.ProjectID == projectId && c.AttendanceDate.Date <= fromDate && c.AttendanceDate.Date >= toDate && c.TenantId == TenantId).ToListAsync(); + + + List projectteam = await _projectsHelper.GetTeamByProject(TenantId, projectId, true); foreach (ProjectAllocation teamMember in projectteam) { @@ -143,6 +141,68 @@ namespace MarcoBMS.Services.Controllers return Ok(ApiResponse.SuccessResponse(result, System.String.Format("{0} Attendance records fetched successfully", result.Count), 200)); } + /// + /// + /// + /// ProjectID + /// YYYY-MM-dd + /// + [HttpGet("project/team")] + + public async Task EmployeeAttendanceByProject([FromQuery] int projectId, [FromQuery] string? date = null) + { + int TenantId = GetUserId(); + DateTime forDate = new DateTime(); + + if (date != null && DateTime.TryParse(date, out forDate) == false) + { + return StatusCode(400, ApiResponse.SuccessResponse(date, "Invalid Date", 400));// new { error = ex.Message }); + + } + if (projectId <= 0) + { + return BadRequest("Project ID is required and must be greater than zero."); + } + + var result = new List(); + Attendance attendance = null; + + if (date == null) forDate = DateTime.UtcNow.Date; + + List lstAttendance = await _context.Attendes.Where(c => c.ProjectID == projectId && c.AttendanceDate.Date == forDate && c.TenantId == TenantId).ToListAsync(); + + + List projectteam = await _projectsHelper.GetTeamByProject(TenantId, projectId, true); + foreach (ProjectAllocation teamMember in projectteam) + { + + var result1 = new EmployeeAttendanceVM() + { + EmployeeAvatar = null, + EmployeeId = teamMember.EmployeeId, + FirstName = teamMember.Employee.FirstName, + LastName = teamMember.Employee.LastName + }; + + attendance = lstAttendance.Find(x => x.EmployeeID == teamMember.EmployeeId); + if (attendance != null) + { + result1.Id = attendance.Id; + result1.CheckInTime = attendance.InTime; + result1.CheckOutTime = attendance.OutTime; + result1.Activity = attendance.Activity; + } + + result.Add(result1); + } + + result.Sort(delegate (EmployeeAttendanceVM x, EmployeeAttendanceVM y) { + return x.FirstName.CompareTo(y.FirstName); + }); + + return Ok(ApiResponse.SuccessResponse(result, System.String.Format("{0} Attendance records fetched successfully", result.Count), 200)); + } + [HttpPost] [Route("record")] @@ -159,7 +219,7 @@ namespace MarcoBMS.Services.Controllers Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID && a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ; - + if (attendance != null) { attendance.Comment = recordAttendanceDot.Comment; @@ -210,7 +270,7 @@ namespace MarcoBMS.Services.Controllers attendance = new Attendance(); attendance.TenantId = TenantId; attendance.AttendanceDate = recordAttendanceDot.Date; - // attendance.Activity = recordAttendanceDot.Action; + // attendance.Activity = recordAttendanceDot.Action; attendance.Comment = recordAttendanceDot.Comment; attendance.EmployeeID = recordAttendanceDot.EmployeeID; attendance.ProjectID = recordAttendanceDot.ProjectID; diff --git a/Marco.Pms.Services/Controllers/AuthController.cs b/Marco.Pms.Services/Controllers/AuthController.cs index d722b2a..2259142 100644 --- a/Marco.Pms.Services/Controllers/AuthController.cs +++ b/Marco.Pms.Services/Controllers/AuthController.cs @@ -1,10 +1,18 @@ using Marco.Pms.Model.Authentication; using Marco.Pms.Model.Dtos; +using Marco.Pms.Model.Dtos.Util; +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Entitlements; +using Marco.Pms.Model.Utilities; +using Marco.Pms.Model.ViewModels.Employee; +using MarcoBMS.Services.Helpers; using MarcoBMS.Services.Service; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.Data; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using System.Net; namespace MarcoBMS.Services.Controllers { @@ -15,12 +23,19 @@ namespace MarcoBMS.Services.Controllers private readonly UserManager _userManager; private readonly JwtSettings _jwtSettings; private readonly RefreshTokenService _refreshTokenService; - string tenentId = "1"; - public AuthController(UserManager userManager, JwtSettings jwtSettings, RefreshTokenService refreshTokenService) + private readonly IEmailSender _emailSender; + private readonly IConfiguration _configuration; + private readonly EmployeeHelper _employeeHelper; + //string tenentId = "1"; + public AuthController(UserManager userManager, JwtSettings jwtSettings, RefreshTokenService refreshTokenService, + IEmailSender emailSender, IConfiguration configuration, EmployeeHelper employeeHelper) { _userManager = userManager; _jwtSettings = jwtSettings; _refreshTokenService = refreshTokenService; + _emailSender = emailSender; + _configuration = configuration; + _employeeHelper = employeeHelper; } [HttpPost("login")] @@ -29,20 +44,21 @@ namespace MarcoBMS.Services.Controllers var user = await _userManager.FindByEmailAsync(loginDto.Username); var user1 = await _userManager.Users.FirstOrDefaultAsync(u => u.Email == loginDto.Username || u.PhoneNumber == loginDto.Username); - + if (user == null || !await _userManager.CheckPasswordAsync(user, loginDto.Password)) { return Unauthorized("Invalid username or password."); } - var token = _refreshTokenService.GenerateJwtToken(user.UserName, tenentId, _jwtSettings); - + Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id); //var refreshToken = GenerateRefreshToken(); - var refreshToken = await _refreshTokenService.CreateRefreshToken(user.Id, tenentId, _jwtSettings); + var token = _refreshTokenService.GenerateJwtToken(user.UserName, emp.TenantId.ToString(), _jwtSettings); - return Ok(new { token, refreshToken }); + var refreshToken = await _refreshTokenService.CreateRefreshToken(user.Id, emp.TenantId.ToString(), _jwtSettings); + + return Ok(ApiResponse.SuccessResponse(new { token = token, refreshToken = refreshToken }, "User logged in successfully.", 200)); } [HttpPost("logout")] @@ -72,7 +88,7 @@ namespace MarcoBMS.Services.Controllers } catch (Exception ex) { - // _logger.LogError(ex, "Error during logout"); + // _logger.LogError(ex, "Error during logout"); return StatusCode(500, new { Message = "Internal server error" }); } } @@ -106,10 +122,15 @@ namespace MarcoBMS.Services.Controllers // Generate new JWT token and refresh token var user = await _userManager.FindByIdAsync(refreshToken.UserId); - var newJwtToken = _refreshTokenService.GenerateJwtToken(user.UserName, tenentId, _jwtSettings); - var newRefreshToken = await _refreshTokenService.CreateRefreshToken(user.Id, tenentId, _jwtSettings); + if (user == null) + return BadRequest("Invalid request."); - return Ok(new { token = newJwtToken, refreshToken = newRefreshToken }); + Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id); + + var newJwtToken = _refreshTokenService.GenerateJwtToken(user.UserName, emp.TenantId.ToString(), _jwtSettings); + var newRefreshToken = await _refreshTokenService.CreateRefreshToken(user.Id, emp.TenantId.ToString(), _jwtSettings); + + return Ok(ApiResponse.SuccessResponse(new { token = newJwtToken, refreshToken = newRefreshToken }, "User refresh token generated successfully.", 200)); } [HttpPost("forgot-password")] @@ -118,10 +139,72 @@ namespace MarcoBMS.Services.Controllers var user = await _userManager.FindByEmailAsync(forgotPasswordDto.Email); if (user == null) return NotFound("User not found."); + /* SEND USER REGISTRATION MAIL*/ var token = await _userManager.GeneratePasswordResetTokenAsync(user); + var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}"; + await _emailSender.SendResetPasswordEmail(user.Email, "", resetLink); + + + return Ok(ApiResponse.SuccessResponse(true, "Password reset link sent.", 200)); + } + + [HttpPost("reset-password")] + public async Task ResetPassword([FromBody] ResetPasswordDto model) + { + var user = await _userManager.FindByEmailAsync(model.Email); + if (user == null) + return BadRequest("Invalid request."); + + // var isTokenValid = await _userManager.VerifyUserTokenAsync(user,UserManager.ResetPasswordTokenPurpose, model.ResetCode); + var isTokenValid = await _userManager.VerifyUserTokenAsync( + user, + TokenOptions.DefaultProvider, // This is the token provider + UserManager.ResetPasswordTokenPurpose, + WebUtility.UrlDecode( model.Token) + ); + + + if (!isTokenValid) + return BadRequest("Invalid or expired token."); + + var result = await _userManager.ResetPasswordAsync(user, WebUtility.UrlDecode(model.Token), model.NewPassword); + if (!result.Succeeded) + return BadRequest(result.Errors); + + return Ok(ApiResponse.SuccessResponse(result.Succeeded, "Password reset successfully.", 200)); + } + + + + [HttpPost("sendmail")] + public async Task SendEmail([FromBody] EmailDot emailDot) + { + + + + var user = await _userManager.FindByEmailAsync(emailDot.ToEmail); + if (user == null) + { + return BadRequest("User not found."); + } + + /* New User*/ + //var token = await _userManager.GeneratePasswordResetTokenAsync(user); + //var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}"; + + //await _emailSender.SendResetPasswordEmailOnRegister(emailDot.ToEmail, "Vikas", resetLink); + + + /* Forget password*/ + // var token = await _userManager.GeneratePasswordResetTokenAsync(user); + + var token = await _userManager.GenerateUserTokenAsync(user, TokenOptions.DefaultProvider, "ResetPassword"); + + var isTokenValid = await _userManager.VerifyUserTokenAsync(user, TokenOptions.DefaultProvider, "ResetPassword", token); + + var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}"; + await _emailSender.SendResetPasswordEmail(user.Email, "", resetLink); - // Send token via email (implementation omitted) - // ... return Ok("Password reset link sent."); } diff --git a/Marco.Pms.Services/Controllers/EmployeeController.cs b/Marco.Pms.Services/Controllers/EmployeeController.cs index 18d3924..933a402 100644 --- a/Marco.Pms.Services/Controllers/EmployeeController.cs +++ b/Marco.Pms.Services/Controllers/EmployeeController.cs @@ -1,17 +1,19 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; using Marco.Pms.Model.Dtos.Employees; using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.Mapper; using Marco.Pms.Model.Utilities; using Marco.Pms.Model.ViewModels; +using Marco.Pms.Model.ViewModels.Employee; +using MarcoBMS.Services.Helpers; using MarcoBMS.Services.Service; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Data; +using System.Net; namespace MarcoBMS.Services.Controllers { @@ -22,18 +24,23 @@ namespace MarcoBMS.Services.Controllers public class EmployeeController : ControllerBase { - private readonly IUnitOfWork _unitOfWork; private readonly ApplicationDbContext _context; private readonly UserManager _userManager; private readonly IEmailSender _emailSender; + private readonly EmployeeHelper _employeeHelper; + private readonly UserHelper _userHelper; + private readonly IConfiguration _configuration; - public EmployeeController(UserManager userManager, IEmailSender emailSender, IEmployeeRepository empRepo, IUnitOfWork unitOfWork, ApplicationDbContext context) + public EmployeeController(UserManager userManager, IEmailSender emailSender, + ApplicationDbContext context, EmployeeHelper employeeHelper, UserHelper userHelper, IConfiguration configuration) { - _unitOfWork = unitOfWork; _context = context; _userManager = userManager; _emailSender = emailSender; + _employeeHelper = employeeHelper; + _userHelper = userHelper; + _configuration = configuration; } [HttpGet] @@ -89,7 +96,7 @@ namespace MarcoBMS.Services.Controllers if (existingItem == null) { - + _context.EmployeeRoleMappings.Add(mapping); } else @@ -99,11 +106,25 @@ namespace MarcoBMS.Services.Controllers } await _context.SaveChangesAsync(); } - catch (Exception ex) { + catch (Exception ex) + { } return Ok(ApiResponse.SuccessResponse("success", "Roles modified.", 200)); } + [HttpGet] + [Route("list/{projectid?}")] + public async Task GetEmployeesByProject(int? projectid) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + var result = await _employeeHelper.GetEmployeeByProjectId(GetTenantId(), projectid); + + return Ok(ApiResponse.SuccessResponse(result, "Filter applied.", 200)); + + } [HttpGet] [Route("search/{name}/{projectid?}")] public async Task SearchEmployee(string name, int? projectid) @@ -112,98 +133,37 @@ namespace MarcoBMS.Services.Controllers { return BadRequest(ModelState); } - int TenantId = GetTenantId(); - name = name.ToLower(); - int tenantId = GetTenantId(); - List employees = await _unitOfWork.Employee.GetAsync(c => c.TenantId == tenantId && (c.FirstName.ToLower().StartsWith(name) - || c.MiddleName.ToLower().StartsWith(name) || c.LastName.ToLower().StartsWith(name))); - - - employees = employees.Where(c => c.FirstName.ToLower().StartsWith(name) - || c.MiddleName.ToLower().StartsWith(name) || c.LastName.ToLower().StartsWith(name)).ToList(); - - if (projectid != null) - { - // conditions to e checked after project assignment - } - return Ok(ApiResponse.SuccessResponse(employees, "Filter applied.", 200)); + var result = await _employeeHelper.SearchEmployeeByProjectId(GetTenantId(), name.ToLower(), projectid); + return Ok(ApiResponse.SuccessResponse(result, "Filter applied.", 200)); } [HttpGet] - [Route("get/{projectid?}")] - public async Task GetEmployee(int? projectid) + [Route("profile/get/{employeeId}")] + public async Task GetEmployeeProfileById(int employeeId) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - int TenantId = GetTenantId(); - List employees = await _unitOfWork.Employee.GetAsync(c => c.TenantId == TenantId); + Employee emp = await _employeeHelper.GetEmployeeByID(employeeId); + EmployeeVM employeeVM = EmployeeMapper.ToEmployeeVMFromEmployee(emp); - employees = employees.Where(c => c.TenantId == TenantId).ToList(); - - if (projectid != null) - { - // Fetch assigned project - } - - return Ok(employees); + return Ok(ApiResponse.SuccessResponse(employeeVM, "Employee Profile.", 200)); } - //[HttpGet] - //[Route("attendance/project/{projectid?}")] - //public async Task GetAttendanceList(int? projectid) - //{ - // if (!ModelState.IsValid) - // { - // return BadRequest(ModelState); - // } - // int TenantId = GetTenantId(); - - - // DateTime today = DateTime.Today; - - // var result = from employee in _context.ProjectAllocations - // join attendance in _context.Attendances - // on employee.Id equals attendance.EmployeeID into attendanceGroup - // from todayAttendance in attendanceGroup - // //.Where(a => a.InTimeLog.InTime == today) - // .DefaultIfEmpty() // LEFT JOIN - // select new - // { - // ProjectID = projectid, - // EmployeeId = employee.Id, - // FirstName = employee.Employee.FirstName, - // MiddleName = employee.Employee.MiddleName, - // LastName = employee.Employee.LastName, - // PhoneNumber = employee.Employee.PhoneNumber, - // RoleId = employee.Employee.JobRoleId, - // //InTime = todayAttendance.InTimeLog != null ? todayAttendance.InTimeLog.InTime : (DateTime?)null, - // //OutTime = todayAttendance.OutTimeLog != null ? todayAttendance.OutTimeLog.OutTime : (DateTime?)null, - // // WorkShift = todayAttendance.WorkShift, - // Latitude = todayAttendance.InTimeLog != null ? todayAttendance.InTimeLog.Latitude : null, - // Longitude = todayAttendance.InTimeLog != null ? todayAttendance.InTimeLog.Longitude : null, - // Comment = todayAttendance.Comment, - // }; - - - - // return Ok(result); - - //} private int GetTenantId() { - var tenant = User.FindFirst("TenantId")?.Value; - return (tenant != null ? Convert.ToInt32(tenant) : 1); + return _userHelper.GetTenantId(); } - [HttpPost("manage/quick")] - public async Task CreateQuickUser([FromBody] CreateQuickUserDto model) - { - return Ok("Pending implementation"); - } + //[HttpPost("manage/quick")] + //public async Task CreateQuickUser([FromBody] CreateQuickUserDto model) + //{ + // return Ok("Pending implementation"); + //} + [HttpPost("manage")] public async Task CreateUser([FromForm] CreateUserDto model) { @@ -211,144 +171,138 @@ namespace MarcoBMS.Services.Controllers return BadRequest("Invalid user data."); int TenantId = GetTenantId(); + string responsemessage = ""; + if (model.Email != null) { // Check if user already exists by email - var existingUser = await _userManager.FindByEmailAsync(model.Email); + IdentityUser? existingUser = await _userHelper.GetRegisteredUser(model.Email); if (existingUser != null) { - // Update existing user - //existingUser.Email = model.Email; // No need to update email - - //var updateResult = await _userManager.UpdateAsync(existingUser); - //if (!updateResult.Succeeded) - // return BadRequest(updateResult.Errors); + /* Identity user Exists - Create/update employee Employee */ // Update Employee record - var existingEmployee = await _context.Employees.FirstOrDefaultAsync(e => e.ApplicationUserId == existingUser.Id); + var existingEmployee = await _context.Employees.FirstOrDefaultAsync(e => e.ApplicationUserId == existingUser.Id || e.Email == model.Email || e.Id == model.Id); if (existingEmployee != null) { - existingEmployee.FirstName = model.FirstName; - existingEmployee.LastName = model.LastName; - existingEmployee.TenantId = TenantId; - existingEmployee.Email = model.Email; - existingEmployee.JobRoleId = Convert.ToInt32(model.JobRoleId); + existingEmployee = GetUpdateEmployeeModel(model, existingEmployee, existingUser); _context.Employees.Update(existingEmployee); } else { // Create Employee record if missing - var newEmployee = new Employee - { - ApplicationUserId = existingUser.Id, - FirstName = model.FirstName, - LastName = model.LastName, - Email = model.Email, - TenantId = TenantId, - CurrentAddress = model.CurrentAddress, - BirthDate = Convert.ToDateTime(model.BirthDate), - EmergencyPhoneNumber = model.EmergencyPhoneNumber, - AadharNumber = model.AadharNumber, - Gender = model.Gender, - MiddleName = model.MiddleName, - PanNumber = model.PanNumber, - PeramnentAddress = model.PeramnentAddress, - PhoneNumber = model.PhoneNumber, - Photo = GetFileDetails(model.Photo).Result.FileData, - JobRoleId = Convert.ToInt32(model.JobRoleId) - - }; + Employee newEmployee = GetNewEmployeeModel(model, TenantId, existingUser.Id); _context.Employees.Add(newEmployee); } await _context.SaveChangesAsync(); - return Ok(new { message = "User updated successfully." }); + responsemessage = "User updated successfully."; } - - var user = new ApplicationUser + else { - UserName = model.Email, - Email = model.Email, - EmailConfirmed = true - }; + var user = new ApplicationUser + { + UserName = model.Email, + Email = model.Email, + EmailConfirmed = true + }; - // Create Identity User - var result = await _userManager.CreateAsync(user, "User@123"); - if (!result.Succeeded) - return BadRequest(result.Errors); + // Create Identity User + var result = await _userManager.CreateAsync(user, "User@123"); + if (!result.Succeeded) + return BadRequest(result.Errors); - // Save Employee Data - var employee = new Employee - { - FirstName = model.FirstName, - LastName = model.LastName, - Email = model.Email, - TenantId = TenantId, - CurrentAddress = model.CurrentAddress, - BirthDate = Convert.ToDateTime(model.BirthDate), - EmergencyPhoneNumber = model.EmergencyPhoneNumber, - AadharNumber = model.AadharNumber, - Gender = model.Gender, - MiddleName = model.MiddleName, - PanNumber = model.PanNumber, - PeramnentAddress = model.PeramnentAddress, - PhoneNumber = model.PhoneNumber, - Photo = GetFileDetails(model.Photo).Result.FileData, - JobRoleId = Convert.ToInt32(model.JobRoleId) - }; - _context.Employees.Add(employee); - await _context.SaveChangesAsync(); + Employee newEmployee = GetNewEmployeeModel(model, TenantId, user.Id); + _context.Employees.Add(newEmployee); - var token = await _userManager.GeneratePasswordResetTokenAsync(user); - var resetLink = Url.Action("ResetPassword", "Account", new { token, email = user.Email }, Request.Scheme); + await _context.SaveChangesAsync(); - // Send Email - await _emailSender.SendEmailAsync(user.Email, "Set Password", $"Click here to set your password: {resetLink}"); + + /* SEND USER REGISTRATION MAIL*/ + var token = await _userManager.GeneratePasswordResetTokenAsync(user); + var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}"; + await _emailSender.SendResetPasswordEmailOnRegister(user.Email, newEmployee.FirstName, resetLink); + + responsemessage = "User created successfully. PAssword reset link is sent to registered email"; + } } else { var existingEmployee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == model.Id); if (existingEmployee != null) { - existingEmployee.FirstName = model.FirstName; - existingEmployee.LastName = model.LastName; - existingEmployee.TenantId = TenantId; - + existingEmployee = GetUpdateEmployeeModel(model, existingEmployee); _context.Employees.Update(existingEmployee); + responsemessage = "User updated successfully."; } else { // Create Employee record if missing - var newEmployee = new Employee - { - ApplicationUserId = null, - FirstName = model.FirstName, - LastName = model.LastName, - TenantId = TenantId, - CurrentAddress = model.CurrentAddress, - BirthDate = Convert.ToDateTime(model.BirthDate), - EmergencyPhoneNumber = model.EmergencyPhoneNumber, - AadharNumber = model.AadharNumber, - Gender = model.Gender, - MiddleName = model.MiddleName, - PanNumber = model.PanNumber, - PeramnentAddress = model.PeramnentAddress, - PhoneNumber = model.PhoneNumber, - Photo = GetFileDetails(model.Photo).Result.FileData + Employee newEmployee = GetNewEmployeeModel(model, TenantId, null); - }; _context.Employees.Add(newEmployee); } await _context.SaveChangesAsync(); + responsemessage = "User created successfully."; + } - // Generate Password Reset Link + return Ok(new { message = responsemessage }); + } + private static Employee GetNewEmployeeModel(CreateUserDto model, int TenantId, string? ApplicationUserId) + { + var newEmployee = new Employee + { + ApplicationUserId = ApplicationUserId, + FirstName = model.FirstName, + LastName = model.LastName, + Email = model.Email, + TenantId = TenantId, + CurrentAddress = model.CurrentAddress, + BirthDate = Convert.ToDateTime(model.BirthDate), + EmergencyPhoneNumber = model.EmergencyPhoneNumber, + EmergencyContactPerson = model.EmergencyContactPerson, + AadharNumber = model.AadharNumber, + Gender = model.Gender, + MiddleName = model.MiddleName, + PanNumber = model.PanNumber, + PeramnentAddress = model.PeramnentAddress, + PhoneNumber = model.PhoneNumber, + Photo = null, // GetFileDetails(model.Photo).Result.FileData, + JobRoleId = Convert.ToInt32(model.JobRoleId), + JoiningDate = Convert.ToDateTime(model.JoiningDate), - return Ok(new { message = "User created successfully. Password reset link sent." }); + }; + return newEmployee; + } + + private static Employee GetUpdateEmployeeModel(CreateUserDto model, Employee existingEmployee, IdentityUser? existingIdentityUser = null) + { + if (existingEmployee.ApplicationUserId == null && existingIdentityUser != null) + { + existingEmployee.ApplicationUserId = existingIdentityUser.Id; + } + existingEmployee.FirstName = model.FirstName; + existingEmployee.LastName = model.LastName; + existingEmployee.CurrentAddress = model.CurrentAddress; + existingEmployee.BirthDate = Convert.ToDateTime(model.BirthDate); + existingEmployee.JoiningDate = Convert.ToDateTime(model.JoiningDate); + existingEmployee.EmergencyPhoneNumber = model.EmergencyPhoneNumber; + existingEmployee.EmergencyContactPerson = model.EmergencyContactPerson; + existingEmployee.AadharNumber = model.AadharNumber; + existingEmployee.Gender = model.Gender; + existingEmployee.MiddleName = model.MiddleName; + existingEmployee.PanNumber = model.PanNumber; + existingEmployee.PeramnentAddress = model.PeramnentAddress; + existingEmployee.PhoneNumber = model.PhoneNumber; + existingEmployee.Photo = null; // GetFileDetails(model.Photo).Result.FileData, + existingEmployee.JobRoleId = Convert.ToInt32(model.JobRoleId); + + return existingEmployee; } private static async Task GetFileDetails(IFormFile file) diff --git a/Marco.Pms.Services/Controllers/FileController.cs b/Marco.Pms.Services/Controllers/FileController.cs index ab77138..ffec508 100644 --- a/Marco.Pms.Services/Controllers/FileController.cs +++ b/Marco.Pms.Services/Controllers/FileController.cs @@ -40,16 +40,16 @@ namespace MarcoBMS.Services.Controllers return imageName; } - [HttpPost("manage1")] - public async Task CreateUser_1([FromForm] CreateUserDto model) - { - if (model == null) - return BadRequest("Invalid user data."); + //[HttpPost("manage1")] + //public async Task CreateUser_1([FromForm] CreateUserDto model) + //{ + // if (model == null) + // return BadRequest("Invalid user data."); - await GetFileDetails(model.Photo); + // await GetFileDetails(model.Photo); - return Ok(new { message = "User created successfully. Password reset link sent." }); - } + // return Ok(new { message = "User created successfully. Password reset link sent." }); + //} private static async Task GetFileDetails(IFormFile file) { diff --git a/Marco.Pms.Services/Controllers/ProjectController.cs b/Marco.Pms.Services/Controllers/ProjectController.cs index 8b0fecd..4ca7a23 100644 --- a/Marco.Pms.Services/Controllers/ProjectController.cs +++ b/Marco.Pms.Services/Controllers/ProjectController.cs @@ -1,6 +1,4 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; using Marco.Pms.Model.Activities; using Marco.Pms.Model.Dtos.Project; using Marco.Pms.Model.Employees; @@ -9,6 +7,8 @@ using Marco.Pms.Model.Mapper; using Marco.Pms.Model.Projects; using Marco.Pms.Model.Utilities; using Marco.Pms.Model.ViewModels; +using Marco.Pms.Model.ViewModels.Employee; +using MarcoBMS.Services.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -21,19 +21,21 @@ namespace MarcoBMS.Services.Controllers [Authorize] public class ProjectController : ControllerBase { - private readonly IUnitOfWork _unitOfWork; + //private readonly IUnitOfWork _unitOfWork; private readonly ApplicationDbContext _context; private ApplicationUser _applicationUser; - private readonly IProjectRepository _projectrepo; + // private readonly IProjectRepository _projectrepo; private readonly UserManager _userManager; + private readonly UserHelper _userHelper; - public ProjectController(UserManager userManager, IProjectRepository projectrepo, IUnitOfWork unitOfWork, ApplicationDbContext context) + + public ProjectController(UserManager userManager, ApplicationDbContext context, UserHelper userHelper) { - _unitOfWork = unitOfWork; + //_unitOfWork = unitOfWork; _context = context; - _projectrepo = projectrepo; + //_projectrepo = projectrepo; _userManager = userManager; - + _userHelper = userHelper; } [HttpGet("list")] public async Task GetAll() @@ -42,8 +44,7 @@ namespace MarcoBMS.Services.Controllers { return BadRequest(ModelState); } - List project = await _projectrepo.GetAllAsync(); - // var commentDto = comments.Select(x => x.ToCommentDto()); + List project = await _context.Projects.Where(c=>c.TenantId == _userHelper.GetTenantId()).ToListAsync(); return Ok(project); } @@ -56,9 +57,7 @@ namespace MarcoBMS.Services.Controllers return BadRequest(ModelState); } - var project = _projectrepo.Get(c => c.Id == id); //_context.Stock.FindAsync(id); - - // List project = await _projectrepo.GetAsync(id); + var project = await _context.Projects.Where(c => c.TenantId == _userHelper.GetTenantId() && c.Id == id).SingleOrDefaultAsync(); return Ok(project); } @@ -73,19 +72,17 @@ namespace MarcoBMS.Services.Controllers return BadRequest(ModelState); } - var projects = await _projectrepo.GetAsync((c => c.Id == id), 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 (projects == null) + if (project == null) { - //vm.project = new Project(); - //vm.buildings = new List(); - //vm.floors = new List(); - //vm.workAreas = new List(); + return Ok(new ProjectVM()); + } else { - var project = projects.Where(c => c.Id == id).SingleOrDefault(); - ProjectDetailsVM vm = GetProjectViewModel(id, project); + //var project = projects.Where(c => c.Id == id).SingleOrDefault(); + ProjectDetailsVM vm = await GetProjectViewModel(id, project); ProjectVM projectVM = new ProjectVM(); projectVM.Id = vm.project.Id; @@ -132,25 +129,26 @@ namespace MarcoBMS.Services.Controllers return Ok(projectVM); } - return Ok(new ProjectVM()); + } - private ProjectDetailsVM GetProjectViewModel(int? id, Project project) + private async Task GetProjectViewModel(int? id, Project project) { ProjectDetailsVM vm = new ProjectDetailsVM(); // List buildings = _unitOfWork.Building.GetAll(c => c.ProjectId == id).ToList(); - List buildings = _context.Buildings.Where(c => c.ProjectId == id).ToList(); + List buildings = await _context.Buildings.Where(c => c.ProjectId == id).ToListAsync(); List idList = buildings.Select(o => o.Id).ToList(); // List floors = _unitOfWork.Floor.GetAll(c => idList.Contains(c.Id)).ToList(); - List floors = _context.Floor.Where(c => idList.Contains(c.BuildingId)).ToList(); + List floors = await _context.Floor.Where(c => idList.Contains(c.BuildingId)).ToListAsync(); idList = floors.Select(o => o.Id).ToList(); //List workAreas = _unitOfWork.WorkArea.GetAll(c => idList.Contains(c.Id), includeProperties: "WorkItems,WorkItems.ActivityMaster").ToList(); - List workAreas = _context.WorkAreas.Where(c => idList.Contains(c.FloorId)).ToList(); + List workAreas = await _context.WorkAreas.Where(c => idList.Contains(c.FloorId)).ToListAsync(); idList = floors.Select(o => o.Id).ToList(); - List workItems = _unitOfWork.WorkItem.GetAll(c => idList.Contains(c.WorkAreaId), includeProperties: "ActivityMaster").ToList(); + List workItems = await _context.WorkItems.Where(c => idList.Contains(c.WorkAreaId)).Include(c=>c.ActivityMaster).ToListAsync(); + // List workItems = _unitOfWork.WorkItem.GetAll(c => idList.Contains(c.WorkAreaId), includeProperties: "ActivityMaster").ToList(); vm.project = project; vm.buildings = buildings; @@ -163,8 +161,9 @@ namespace MarcoBMS.Services.Controllers private int GetTenantId() { - var tenant = User.FindFirst("TenantId")?.Value; - return (tenant != null ? Convert.ToInt32(tenant) : 1); + return _userHelper.GetTenantId(); + //var tenant = User.FindFirst("TenantId")?.Value; + //return (tenant != null ? Convert.ToInt32(tenant) : 1); } [HttpPost] @@ -176,26 +175,13 @@ namespace MarcoBMS.Services.Controllers } int TenantId = GetTenantId(); - var projectModel = projectDto.ToProjectFromCreateProjectDto(TenantId); + var project = projectDto.ToProjectFromCreateProjectDto(TenantId); - var result = await _projectrepo.CreateAsync(projectModel); + _context.Projects.Add(project); - return Ok(result); + await _context.SaveChangesAsync(); - } - - [HttpGet("get-allocation/{projectId:int}")] - public async Task GetAllocation([FromRoute] int projectId) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - List allocations = await _unitOfWork.ProjectAllocation.GetAsync(c => c.ProjectId == projectId); - allocations = allocations.Where(c => c.ProjectId == projectId).ToList(); - - return Ok(allocations); + return Ok(ApiResponse.SuccessResponse(project.ToProjectDto(), "Success.", 200)); } [HttpPut] @@ -210,13 +196,14 @@ namespace MarcoBMS.Services.Controllers { int TenantId = GetTenantId(); updateProjectDto.TenantId = TenantId; - var projectModel = await _projectrepo.UpdateAsync(id, updateProjectDto); - if (projectModel == null) - { - return NotFound("Project not found"); - } - return Ok(projectModel.ToProjectDto()); + Project project = updateProjectDto.ToProjectFromUpdateProjectDto(TenantId); + _context.Projects.Update(project); + + await _context.SaveChangesAsync(); + + return Ok(ApiResponse.SuccessResponse(project.ToProjectDto(), "Success.", 200)); + } catch (Exception ex) { @@ -225,49 +212,96 @@ namespace MarcoBMS.Services.Controllers } - [HttpPost("assign-employee")] - public async Task AssignEmployee(int? allocationid, int employeeId, int projectId) + //[HttpPost("assign-employee")] + //public async Task AssignEmployee(int? allocationid, int employeeId, int projectId) + //{ + // var employee = await _context.Employees.FindAsync(employeeId); + // var project = _projectrepo.Get(c => c.Id == projectId); + // if (employee == null || project == null) + // { + // return NotFound(); + // } + + // // Logic to add the product to a new table (e.g., selected products) + + // if (allocationid == null) + // { + // // Add allocation + // ProjectAllocation allocation = new ProjectAllocation() + // { + // EmployeeId = employeeId, + // ProjectId = project.Id, + // AllocationDate = DateTime.UtcNow, + // //EmployeeRole = employee.Rol + // TenantId = project.TenantId + // }; + + // _unitOfWork.ProjectAllocation.CreateAsync(allocation); + // } + // else + // { + // //remove allocation + // var allocation = await _context.ProjectAllocations.FindAsync(allocationid); + // if (allocation != null) + // { + // allocation.ReAllocationDate = DateTime.UtcNow; + + // _unitOfWork.ProjectAllocation.UpdateAsync(allocation.Id, allocation); + // } + // else + // { + // return NotFound(); + // } + // } + + // return Ok(); + //} + + [HttpGet] + [Route("employees/get/{projectid?}/{includeInactive?}")] + public async Task GetEmployeeByProjectID(int? projectid, bool? includeInactive = false) { - var employee = await _context.Employees.FindAsync(employeeId); - var project = _projectrepo.Get(c => c.Id == projectId); - if (employee == null || project == null) + if (!ModelState.IsValid) { - return NotFound(); + return BadRequest(ModelState); } + int TenantId = GetTenantId(); - // Logic to add the product to a new table (e.g., selected products) - - if (allocationid == null) + if (projectid != null) { - // Add allocation - ProjectAllocation allocation = new ProjectAllocation() - { - EmployeeId = employeeId, - ProjectId = project.Id, - AllocationDate = DateTime.UtcNow, - //EmployeeRole = employee.Rol - TenantId = project.TenantId - }; + // Fetch assigned project + List result = new List(); - _unitOfWork.ProjectAllocation.CreateAsync(allocation); + if ((bool)includeInactive) + { + + result = await (from rpm in _context.Employees.Include(c => c.JobRole) + join fp in _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectid) + on rpm.Id equals fp.EmployeeId + select rpm).ToListAsync(); + }else + { + 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) + on rpm.Id equals fp.EmployeeId + select rpm).ToListAsync(); + } + + List resultVM = new List(); + foreach (Employee employee in result) + { + EmployeeVM vm = employee.ToEmployeeVMFromEmployee(); + resultVM.Add(vm); + } + + return Ok(ApiResponse.SuccessResponse(resultVM, "Success.", 200)); } else { - //remove allocation - var allocation = await _context.ProjectAllocations.FindAsync(allocationid); - if (allocation != null) - { - allocation.ReAllocationDate = DateTime.UtcNow; - - _unitOfWork.ProjectAllocation.UpdateAsync(allocation.Id, allocation); - } - else - { - return NotFound(); - } + return Ok(ApiResponse.ErrorResponse("Invalid Input Parameter", 422)); } - return Ok(); + } [HttpGet] @@ -280,25 +314,25 @@ namespace MarcoBMS.Services.Controllers } int TenantId = GetTenantId(); - var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == projectId ).Include(e => e.Employee).Select(e=> new + + 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 { ID = e.Id, EmployeeId = e.EmployeeId, ProjectId = e.ProjectId, - RoleID = e.EmployeeRoleId, AllocationDate = e.AllocationDate, ReAllocationDate = e.ReAllocationDate, - FirstName = e.Employee.FirstName, - LastName = e.Employee.LastName, + FirstName = e.Employee.FirstName, + LastName = e.Employee.LastName, MiddleName = e.Employee.MiddleName, - IsActive = e.IsActive - + IsActive = e.IsActive, + JobRoleId = (e.JobRoleId != null ? e.JobRoleId : e.Employee.JobRoleId) }).ToListAsync(); return Ok(ApiResponse.SuccessResponse(employees, "Success.", 200)); } - [HttpPost("allocation")] + [HttpPost("allocation")] public async Task ManageAllocation(List projectAllocationDot) { if (projectAllocationDot != null) @@ -310,9 +344,9 @@ namespace MarcoBMS.Services.Controllers try { ProjectAllocation projectAllocation = item.ToProjectAllocationFromProjectAllocationDto(TenentID); - ProjectAllocation projectAllocationFromDb =await _context.ProjectAllocations.Where(c => c.EmployeeId == projectAllocation.EmployeeId - && c.ProjectId == projectAllocation.ProjectId - && c.ReAllocationDate == null + ProjectAllocation projectAllocationFromDb = await _context.ProjectAllocations.Where(c => c.EmployeeId == projectAllocation.EmployeeId + && c.ProjectId == projectAllocation.ProjectId + && c.ReAllocationDate == null && c.TenantId == TenentID).SingleOrDefaultAsync(); if (projectAllocationFromDb != null) @@ -321,11 +355,10 @@ namespace MarcoBMS.Services.Controllers if (item.Status) { - projectAllocationFromDb.EmployeeRoleId = projectAllocation.EmployeeRoleId; ; + projectAllocationFromDb.JobRoleId = projectAllocation.JobRoleId; ; projectAllocationFromDb.IsActive = true; - _context.Entry(projectAllocationFromDb).Property(e => e.EmployeeRoleId).IsModified = true; + _context.Entry(projectAllocationFromDb).Property(e => e.JobRoleId).IsModified = true; _context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true; - } else { @@ -333,7 +366,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; - } await _context.SaveChangesAsync(); @@ -371,20 +403,15 @@ namespace MarcoBMS.Services.Controllers if (item.Id > 0) { //update - - _unitOfWork.WorkItem.Update(workItem); - + _context.WorkItems.Update(workItem); + await _context.SaveChangesAsync(); } else { - //create - _unitOfWork.WorkItem.Add(workItem); - + _context.WorkItems.Add(workItem); + await _context.SaveChangesAsync(); } - - _unitOfWork.Save(); - } return Ok(ApiResponse.SuccessResponse(null, "Data saved successfully.", 200)); @@ -410,15 +437,15 @@ namespace MarcoBMS.Services.Controllers if (item.Building.Id == 0) { //create - _unitOfWork.Building.Add(building); + _context.Buildings.Add(building); + await _context.SaveChangesAsync(); } else { //update - _unitOfWork.Building.Update(building); + _context.Buildings.Update(building); + await _context.SaveChangesAsync(); } - - _unitOfWork.Save(); } if (item.Floor != null) { @@ -428,16 +455,15 @@ namespace MarcoBMS.Services.Controllers if (item.Floor.Id == 0) { //create - _unitOfWork.Floor.Add(floor); + _context.Floor.Add(floor); + await _context.SaveChangesAsync(); } else { //update - _unitOfWork.Floor.Update(floor); + _context.Floor.Update(floor); + await _context.SaveChangesAsync(); } - - _unitOfWork.Save(); - } if (item.WorkArea != null) { @@ -447,15 +473,15 @@ namespace MarcoBMS.Services.Controllers if (item.WorkArea.Id == 0) { //create - _unitOfWork.WorkArea.Add(workArea); + _context.WorkAreas.Add(workArea); + await _context.SaveChangesAsync(); } else { //update - _unitOfWork.WorkArea.Update(workArea); + _context.WorkAreas.Update(workArea); + await _context.SaveChangesAsync(); } - - _unitOfWork.Save(); } } } diff --git a/Marco.Pms.Services/Controllers/RolesController.cs b/Marco.Pms.Services/Controllers/RolesController.cs index 800e7a2..8d654df 100644 --- a/Marco.Pms.Services/Controllers/RolesController.cs +++ b/Marco.Pms.Services/Controllers/RolesController.cs @@ -1,9 +1,11 @@ -using Marco.Pms.DataAccess.Data; +using Azure; +using Marco.Pms.DataAccess.Data; using Marco.Pms.Model.Dtos.Roles; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.Mapper; using Marco.Pms.Model.Utilities; using Marco.Pms.Model.ViewModels; +using MarcoBMS.Services.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -18,13 +20,16 @@ namespace MarcoBMS.Services.Controllers public class RolesController : ControllerBase { private readonly ApplicationDbContext _context; + private readonly RolesHelper _rolesHelper; + private readonly UserManager _userManager; - public RolesController(UserManager userManager, ApplicationDbContext context) + public RolesController(UserManager userManager, ApplicationDbContext context, RolesHelper rolesHelper) { _context = context; _userManager = userManager; + _rolesHelper = rolesHelper; } @@ -154,8 +159,7 @@ namespace MarcoBMS.Services.Controllers } - - return Ok(applicationRoles); + return Ok(ApiResponse.SuccessResponse(applicationRoles, "Roles list fetched successfully.", 200)); } @@ -214,21 +218,34 @@ namespace MarcoBMS.Services.Controllers return NotFound("Project not found"); } + bool modified = false; foreach (var permission in updateRoleDto.FeaturesPermission) { var item = new RolePermissionMappings() { ApplicationRoleId = role.Id, FeaturePermissionId = permission.Id }; bool assigned = _context.RolePermissionMappings.Any(c => c.ApplicationRoleId == role.Id && c.FeaturePermissionId == permission.Id); - if (permission.IsEnabled && !assigned) - _context.RolePermissionMappings.Add(item); - else + if (permission.IsEnabled == false && assigned == true) + { _context.RolePermissionMappings.Remove(item); - + modified = true; + } + else if (permission.IsEnabled && !assigned) + { + _context.RolePermissionMappings.Add(item); + modified = true; + } } - return Ok(role.ToRoleVMFromApplicationRole()); + if (modified) + await _context.SaveChangesAsync(); + + ApplicationRolesVM response = role.ToRoleVMFromApplicationRole(); + List permissions = await _rolesHelper.GetFeaturePermissionByRoleID(response.Id); + response.FeaturePermission = permissions.Select(c => c.ToFeaturePermissionVMFromFeaturePermission()).ToList(); + + return Ok(ApiResponse.SuccessResponse(response, "Roles perimssions updated.", 200)); } catch (Exception ex) { - return Ok(null); + return Ok(ApiResponse.ErrorResponse( "RUnable to update roles perimssions.", 200)); } } @@ -269,7 +286,8 @@ namespace MarcoBMS.Services.Controllers FeaturePermission = featurePermissions }; - return Ok(vm); + return Ok(ApiResponse.SuccessResponse(vm, "Roles Perimssions fetched successfully.", 200)); + } } } diff --git a/Marco.Pms.Services/Controllers/TaskController.cs b/Marco.Pms.Services/Controllers/TaskController.cs index 9e5d978..3066f9f 100644 --- a/Marco.Pms.Services/Controllers/TaskController.cs +++ b/Marco.Pms.Services/Controllers/TaskController.cs @@ -1,8 +1,6 @@ using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository.IRepository; -using Marco.Pms.Model.Entitlements; +using MarcoBMS.Services.Helpers; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -13,32 +11,23 @@ namespace MarcoBMS.Services.Controllers [ApiController] public class TaskController : ControllerBase { - private readonly IUnitOfWork _unitOfWork; private readonly ApplicationDbContext _context; - private ApplicationUser _applicationUser; - private readonly IActivityMasterRepository _activityRepo; - private readonly IHttpContextAccessor _httpContextAccessor; + private readonly UserHelper _userHelper; - public TaskController(IActivityMasterRepository activityRepo, IUnitOfWork unitOfWork, ApplicationDbContext context, IHttpContextAccessor httpContextAccessor) + + public TaskController(ApplicationDbContext context, UserHelper userHelper) { - _unitOfWork = unitOfWork; _context = context; - _activityRepo = activityRepo; - _httpContextAccessor = httpContextAccessor; + _userHelper = userHelper; } [HttpGet] [Route("activities")] public async Task GetActivities() { - var tenantId = _httpContextAccessor.HttpContext?.Items["TenantId"]?.ToString(); - - - var activities = await _activityRepo.GetAllAsync(c=>c.TenantId == Convert.ToInt32( tenantId)); + var activities = await _context.ActivityMasters.Where(c => c.TenantId == _userHelper.GetTenantId()).ToListAsync(); return Ok(activities); } - - } } diff --git a/Marco.Pms.Services/Controllers/UserController.cs b/Marco.Pms.Services/Controllers/UserController.cs new file mode 100644 index 0000000..b808a3c --- /dev/null +++ b/Marco.Pms.Services/Controllers/UserController.cs @@ -0,0 +1,68 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Entitlements; +using Marco.Pms.Model.Mapper; +using Marco.Pms.Model.Projects; +using Marco.Pms.Model.ViewModels.Employee; +using MarcoBMS.Services.Helpers; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace MarcoBMS.Services.Controllers +{ + [Route("api/[controller]")] + [ApiController] + [Authorize] + + public class UserController : ControllerBase + { + private readonly UserHelper _userHelper; + private readonly EmployeeHelper _employeeHelper; + + private readonly ProjectsHelper _projectsHelper; + private readonly RolesHelper _rolesHelper; + + public UserController(EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper, RolesHelper rolesHelper) + { + _userHelper = userHelper; + _employeeHelper = employeeHelper; + _projectsHelper = projectsHelper; + _rolesHelper = rolesHelper; + + } + [HttpGet("profile")] + public async Task GetUserProfileFromJwt() + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var user = await _userHelper.GetCurrentUserAsync(); + Employee emp = await _employeeHelper.GetEmployeeByApplicationUserID(user.Id); + + List featurePermission = await _rolesHelper.GetFeaturePermissionByEmployeeID(emp.Id); + string[] projectsId = []; + + if (featurePermission != null && featurePermission.Exists(c => c.FeatureId.ToString() == "53176ebf-c75d-42e5-839f-4508ffac3def")) { + List projects = await _projectsHelper.GetAllProjectByTanentID(emp.TenantId); + projectsId = projects.Select(c=>c.Id.ToString()).ToArray(); + } + else + { + List allocation = await _projectsHelper.GetProjectByEmployeeID(emp.Id); + projectsId = allocation.Select(c => c.ProjectId.ToString()).ToArray(); + } + + + EmployeeVM employeeVM = EmployeeMapper.ToEmployeeVMFromEmployee(emp); + EmployeeProfile profile = new EmployeeProfile() + { + EmployeeInfo = employeeVM, + Projects = projectsId, + FeaturePermissions = featurePermission.Select(c => c.FeatureId.ToString()).ToArray(), + }; + + return Ok(profile); + } + } +} diff --git a/Marco.Pms.Services/EmailTemplates/forgot-password.html b/Marco.Pms.Services/EmailTemplates/forgot-password.html new file mode 100644 index 0000000..a944fd4 --- /dev/null +++ b/Marco.Pms.Services/EmailTemplates/forgot-password.html @@ -0,0 +1,565 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + + + +
+ Sita +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + + + + + + +
+ +
+

{{MAIL_TITLE}}

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Hello,

+

 

+

We have sent you this email in response to your request to reset your password on MarcoPMS.

+

 

+

To reset your password, please follow the link below:

+
+ +
+ + + + + + + +
+ + + + +
+ + + + + + + +
+ +
+

Please ignore this email if you did not request a password change.
 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Contact

+

1912  Mcwhorter Road, FL 11223

+

+111 222 333 | info [@] marcoaiot.com

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + Twitter + +
+ + + + + + + + +
+ + Instagram + +
+ + + + + + + + +
+ + LinkedIn + +
+ + +
+
+ +
+ + + + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+

Marco AIoT Technologies Pvt. Ltd. ©  All Rights Reserved

+ + + +
+ + +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+ You're receiving this email because you have a MarcoPMS account. This email is not a marketing or promotional email. That is why this email does not contain an unsubscribe link. You will receive this email even if you have unsubscribed from MarcoPMS's marketing emails + +
+ +
+ + +
+
+
+ + +
+
+
+ +
+ + + + + diff --git a/Marco.Pms.Services/EmailTemplates/full-template.html b/Marco.Pms.Services/EmailTemplates/full-template.html new file mode 100644 index 0000000..925de8f --- /dev/null +++ b/Marco.Pms.Services/EmailTemplates/full-template.html @@ -0,0 +1,565 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + + + +
+ Sita +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + + + + + + +
+ +
+

Please reset your password

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Hello,

+

 

+

We have sent you this email in response to your request to reset your password on MarcoPMS.

+

 

+

To reset your password, please follow the link below:

+
+ +
+ + + + + + + +
+ + + + +
+ + + + + + + +
+ +
+

Please ignore this email if you did not request a password change.
 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Contact

+

1912  Mcwhorter Road, FL 11223

+

+111 222 333 | info [@] marcoaiot.com

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + Twitter + +
+ + + + + + + + +
+ + Instagram + +
+ + + + + + + + +
+ + LinkedIn + +
+ + +
+
+ +
+ + + + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+

Marco AIoT Technologies Pvt. Ltd. ©  All Rights Reserved

+ + + +
+ + +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+ You're receiving this email because you have a MarcoPMS account. This email is not a marketing or promotional email. That is why this email does not contain an unsubscribe link. You will receive this email even if you have unsubscribed from MarcoPMS's marketing emails + +
+ +
+ + +
+
+
+ + +
+
+
+ +
+ + + + + diff --git a/Marco.Pms.Services/EmailTemplates/new-user-email.html b/Marco.Pms.Services/EmailTemplates/new-user-email.html new file mode 100644 index 0000000..aac8df2 --- /dev/null +++ b/Marco.Pms.Services/EmailTemplates/new-user-email.html @@ -0,0 +1,564 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + + + +
+ Sita +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ + + + + +
+ + Image + +
+ +
+ + + + + + + +
+ +
+

{{MAIL_TITLE}}

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Hello {{RECEIVER_NAME}},

+

 

+

Welcome, You've joined your teammates on MarcoPMS. We have sent you this email to set your password on MarcoPMS.

+

 

+

To set your password, please follow the link below:

+
+ +
+ + + + + + + +
+ + + + +
+ + + + + + + +
+ +
+

Please ignore this email if you did not request a password change.
 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+

Contact

+

1912  Mcwhorter Road, FL 11223

+

+111 222 333 | info [@] marcoaiot.com

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + Twitter + +
+ + + + + + + + +
+ + Instagram + +
+ + + + + + + + +
+ + LinkedIn + +
+ + +
+
+ +
+ + + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + +
+

Marco AIoT Technologies Pvt. Ltd. ©  All Rights Reserved

+ + + +
+ + +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + + + + + + + +
+ +
+ You're receiving this email because you have a MarcoPMS account. This email is not a marketing or promotional email. That is why this email does not contain an unsubscribe link. You will receive this email even if you have unsubscribed from MarcoPMS's marketing emails + +
+ +
+ + +
+
+
+ + +
+
+
+ +
+ + + + + diff --git a/Marco.Pms.Services/Helpers/EmployeeHelper.cs b/Marco.Pms.Services/Helpers/EmployeeHelper.cs index c455781..ca7fae9 100644 --- a/Marco.Pms.Services/Helpers/EmployeeHelper.cs +++ b/Marco.Pms.Services/Helpers/EmployeeHelper.cs @@ -1,20 +1,101 @@ -using Marco.Pms.DataAccess.Data; + +using Marco.Pms.DataAccess.Data; using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Mapper; +using Marco.Pms.Model.ViewModels.Employee; using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Runtime.Intrinsics.Arm; namespace MarcoBMS.Services.Helpers { public class EmployeeHelper { private readonly ApplicationDbContext _context; - public EmployeeHelper(ApplicationDbContext context) { + public EmployeeHelper(ApplicationDbContext context) + { _context = context; } - - public async Task GetEmployeeByID(int EmployeeID) { return await _context.Employees.FindAsync(EmployeeID); } + + public async Task GetEmployeeByApplicationUserID(string ApplicationUserID) + { + try + { + var result = await _context.Employees.Where(c => c.ApplicationUserId == ApplicationUserID).ToListAsync(); + + return await _context.Employees.Where(c => c.ApplicationUserId == ApplicationUserID).SingleOrDefaultAsync(); + } + catch (Exception ex) + { + return null; + } + } + + public async Task> SearchEmployeeByProjectId(int TenentId, string searchString, int? ProjectId) + { + try + { + List result = new List(); + if (ProjectId != null) + { + + 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 + on pa.EmployeeId equals em.Id + where em.FirstName.ToLower().Contains(searchString.ToLower()) || em.LastName.ToLower().Contains(searchString.ToLower()) + select em.ToEmployeeVMFromEmployee() + ) + .ToListAsync(); + + } + else + { + 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) + .Select(c => c.ToEmployeeVMFromEmployee()).ToListAsync(); + } + + return result; + } + catch (Exception ex) + { + return new List(); + } + } + + public async Task> GetEmployeeByProjectId(int TenentId, int? ProjectId) + { + try + { + List result = new List(); + if (ProjectId != null) + { + + 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 + on pa.EmployeeId equals em.Id + select em.ToEmployeeVMFromEmployee() + ) + .ToListAsync(); + + } + else + { + result = await _context.Employees.Where(c => c.TenantId == TenentId).Include(fp => fp.JobRole) + .Select(c => c.ToEmployeeVMFromEmployee()).ToListAsync(); + } + + return result; + } + catch (Exception ex) + { + return new List(); + } + } } } + diff --git a/Marco.Pms.Services/Helpers/ProjectHelper.cs b/Marco.Pms.Services/Helpers/ProjectHelper.cs index 528a3b9..67455aa 100644 --- a/Marco.Pms.Services/Helpers/ProjectHelper.cs +++ b/Marco.Pms.Services/Helpers/ProjectHelper.cs @@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis; using Microsoft.EntityFrameworkCore; -namespace MarcoBMS.Services.Helpers +namespace ModelServices.Helpers { public class ProjectHelper { diff --git a/Marco.Pms.Services/Helpers/ProjectsHelper.cs b/Marco.Pms.Services/Helpers/ProjectsHelper.cs new file mode 100644 index 0000000..7d306bc --- /dev/null +++ b/Marco.Pms.Services/Helpers/ProjectsHelper.cs @@ -0,0 +1,48 @@ +using Marco.Pms.DataAccess.Data; +using Marco.Pms.Model.Projects; +using Microsoft.EntityFrameworkCore; + +namespace MarcoBMS.Services.Helpers +{ + public class ProjectsHelper + { + private readonly ApplicationDbContext _context; + + public ProjectsHelper(ApplicationDbContext context) + { + _context = context; + } + + public async Task> GetAllProjectByTanentID(int tanentID) + { + List alloc = await _context.Projects.Where(c => c.TenantId == tanentID).ToListAsync(); + return alloc; + } + + public async Task> GetProjectByEmployeeID(int employeeID) + { + List alloc = await _context.ProjectAllocations.Where(c => c.EmployeeId ==employeeID && c.IsActive == true).Include(c=>c.Project).ToListAsync(); + return alloc; + } + + public async Task> GetTeamByProject(int TenantId, int ProjectId, bool IncludeInactive) + { + if (IncludeInactive) + { + + var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == ProjectId).Include(e => e.Employee).ToListAsync(); + + return employees; + } + else + { + var employees = await _context.ProjectAllocations.Where(c => c.TenantId == TenantId && c.ProjectId == ProjectId && c.IsActive == true).Include(e => e.Employee).ToListAsync(); + + return employees; + } + } + + + + } +} diff --git a/Marco.Pms.Services/Helpers/RolesHelper.cs b/Marco.Pms.Services/Helpers/RolesHelper.cs new file mode 100644 index 0000000..9bf16fd --- /dev/null +++ b/Marco.Pms.Services/Helpers/RolesHelper.cs @@ -0,0 +1,53 @@ + + +using Marco.Pms.DataAccess.Data; +using Marco.Pms.Model.Entitlements; +using Microsoft.EntityFrameworkCore; + +namespace MarcoBMS.Services.Helpers +{ + public class RolesHelper + { + private readonly ApplicationDbContext _context; + public RolesHelper(ApplicationDbContext context) + { + _context = context; + } + + public async Task> GetFeaturePermissionByEmployeeID(int EmployeeID) + { + List roleMappings = await _context.EmployeeRoleMappings.Where(c => c.EmployeeId ==EmployeeID && c.IsEnabled == true).Select(c=>c.RoleId).ToListAsync(); + + // _context.RolePermissionMappings + + var result = await (from rpm in _context.RolePermissionMappings + join fp in _context.FeaturePermissions.Where(c=>c.IsEnabled == true).Include(fp => fp.Feature) // Include Feature + on rpm.FeaturePermissionId equals fp.Id + where roleMappings.Contains(rpm.ApplicationRoleId) + select fp) + .ToListAsync(); + + return result; + + // return null; + } + + public async Task> GetFeaturePermissionByRoleID(Guid roleId) + { + List roleMappings = await _context.RolePermissionMappings.Where(c => c.ApplicationRoleId == roleId ).Select(c => c.ApplicationRoleId).ToListAsync(); + + // _context.RolePermissionMappings + + var result = await (from rpm in _context.RolePermissionMappings.Where(c=>c.ApplicationRoleId == roleId) + join fp in _context.FeaturePermissions.Where(c => c.IsEnabled == true).Include(fp => fp.Feature) // Include Feature + on rpm.FeaturePermissionId equals fp.Id + select fp) + .ToListAsync(); + + return result; + + // return null; + } + + } +} diff --git a/Marco.Pms.Services/Helpers/UserHelper.cs b/Marco.Pms.Services/Helpers/UserHelper.cs new file mode 100644 index 0000000..4f1d42f --- /dev/null +++ b/Marco.Pms.Services/Helpers/UserHelper.cs @@ -0,0 +1,63 @@ +using Marco.Pms.Model.Dtos.Employees; +using Marco.Pms.Model.Entitlements; +using Microsoft.AspNetCore.Identity; +using System.Security.Claims; + +namespace MarcoBMS.Services.Helpers +{ + public class UserHelper + { + private readonly UserManager _userManager; + private readonly IHttpContextAccessor _httpContextAccessor; + + public UserHelper(UserManager userManager, IHttpContextAccessor httpContextAccessor) + { + _userManager = userManager; + _httpContextAccessor = httpContextAccessor; + } + + public int GetTenantId() + { + var tenant = _httpContextAccessor.HttpContext?.User.FindFirst("TenantId")?.Value; + return (tenant != null ? Convert.ToInt32(tenant) : 1); + } + + public async Task GetCurrentUserAsync() + { + var userId = _httpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier); + + if (string.IsNullOrEmpty(userId)) + return null; + var user = await _userManager.FindByEmailAsync(userId); + return user; //await _userManager.FindByIdAsync(userId); + } + + public async Task GetCurrentUserProfileAsync() + { + + var user = await GetCurrentUserAsync(); + return user == null ? null : new + { + user.Id, + user.UserName, + user.Email, + user.PhoneNumber + }; + } + + public async Task GetRegisteredUser(string email) + { + //IdentityUser? user = await _userManager.Users + // .FirstOrDefaultAsync(u => u.Email == model.Email || u.PhoneNumber == model.PhoneNumber); + + + IdentityUser? user = await _userManager.FindByEmailAsync(email); + //if (user == null) + //{ + // user = await _userManager.Find(model.Email); + + //} + return user; + } + } +} diff --git a/Marco.Pms.Services/Marco.Pms.Services.csproj b/Marco.Pms.Services/Marco.Pms.Services.csproj index 2a1f97d..4e70e23 100644 --- a/Marco.Pms.Services/Marco.Pms.Services.csproj +++ b/Marco.Pms.Services/Marco.Pms.Services.csproj @@ -29,6 +29,9 @@ + + + diff --git a/Marco.Pms.Services/Middleware/LoggingMiddleware.cs b/Marco.Pms.Services/Middleware/LoggingMiddleware.cs new file mode 100644 index 0000000..28535b2 --- /dev/null +++ b/Marco.Pms.Services/Middleware/LoggingMiddleware.cs @@ -0,0 +1,64 @@ +using MarcoBMS.Services.Helpers; +using MarcoBMS.Services.Service; +using Serilog.Context; +using System.Diagnostics; + +namespace MarcoBMS.Services.Middleware +{ + public class LoggingMiddleware + { + private readonly RequestDelegate _next; + private readonly ILogger _logger; + private readonly ILoggingService _loggingService; + //private readonly UserHelper _userHelper; + public LoggingMiddleware(RequestDelegate next, ILogger logger, ILoggingService loggingService) + { + _next = next; + _logger = logger; + //_userHelper = userHelper; + _loggingService = loggingService; + } + + public async Task Invoke(HttpContext context) + { + var stopwatch = Stopwatch.StartNew(); + var response = context.Response; + var request = context.Request; + var tenant = context.User.FindFirst("TenantId")?.Value; + int tenantId = (tenant != null ? Convert.ToInt32(tenant) : 1); + + + using (LogContext.PushProperty("TenantId", tenantId)) + using (LogContext.PushProperty("TraceId", context.TraceIdentifier)) + using (LogContext.PushProperty("UserAgent", request.Headers["User-Agent"].ToString())) + using (LogContext.PushProperty("HttpMethod", request.Method)) + using (LogContext.PushProperty("Timestamp", DateTime.UtcNow)) + using (LogContext.PushProperty("IpAddress", context.Connection.RemoteIpAddress?.ToString())) + using (LogContext.PushProperty("RequestPath", request.Path)) + + + try + { + await _next(context); + stopwatch.Stop(); + using (LogContext.PushProperty("StatusCode", response.StatusCode.ToString())) + using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds)) + using (LogContext.PushProperty("LogLevel", "Information")) + _logger.LogInformation("HTTP {method} {path} responded {statusCode} in {timeTaken} ms", request.Method,request.Path, response.StatusCode.ToString(),stopwatch.ElapsedMilliseconds); + } + catch (Exception ex) + { + stopwatch.Stop(); + using (LogContext.PushProperty("Error", ex)) + using (LogContext.PushProperty("StatusCode", "500")) + using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds)) + using (LogContext.PushProperty("LogLevel", "Error")) + _logger.LogError("API Error{error}", ex.Message); + throw; + } + } + } + +} + + diff --git a/Marco.Pms.Services/Program.cs b/Marco.Pms.Services/Program.cs index c2a26b1..a01ea0e 100644 --- a/Marco.Pms.Services/Program.cs +++ b/Marco.Pms.Services/Program.cs @@ -1,7 +1,4 @@ -using BulkyBook.DataAccess.Repository; using Marco.Pms.DataAccess.Data; -using Marco.Pms.DataAccess.Repository; -using Marco.Pms.DataAccess.Repository.IRepository; using Marco.Pms.Model.Authentication; using Marco.Pms.Model.Utilities; using MarcoBMS.Services.Helpers; @@ -22,10 +19,10 @@ var builder = WebApplication.CreateBuilder(args); // Add Serilog Configuration builder.Host.UseSerilog((context, config) => { - config - .WriteTo.Console(); // Optional: Log to console - // .WriteTo.MongoDB("mongodb://localhost:27017/logs", collectionName: "api_logs"); -}); + config.ReadFrom.Configuration(context.Configuration); // Taking all configuration from appsetting.json + +}) +; // Add services builder.Services.AddCors(options => @@ -98,21 +95,23 @@ builder.Services.AddDbContext(options => builder.Services.AddMemoryCache(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - - - - -builder.Services.AddScoped(); +//builder.Services.AddScoped(); +//builder.Services.AddScoped(); +//builder.Services.AddScoped(); +//builder.Services.AddScoped(); +//builder.Services.AddScoped(); +//builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddSingleton(); + + +builder.Services.AddHttpContextAccessor(); var jwtSettings = builder.Configuration.GetSection("Jwt").Get(); builder.Services.AddAuthentication(options => @@ -150,10 +149,14 @@ if (app.Environment.IsDevelopment()) app.UseCors("DevCorsPolicy"); } +app.UseStaticFiles(); // Enables serving static files + app.UseSerilogRequestLogging(); // Log HTTP requests app.UseHttpsRedirection(); app.UseMiddleware(); app.UseMiddleware(); +app.UseMiddleware(); + app.UseAuthorization(); diff --git a/Marco.Pms.Services/Service/EmailSender.cs b/Marco.Pms.Services/Service/EmailSender.cs index a619601..fd357cf 100644 --- a/Marco.Pms.Services/Service/EmailSender.cs +++ b/Marco.Pms.Services/Service/EmailSender.cs @@ -5,13 +5,61 @@ using MimeKit; namespace MarcoBMS.Services.Service -{ public class EmailSender : IEmailSender +{ + public class EmailSender : IEmailSender { private readonly SmtpSettings _smtpSettings; + private readonly IConfiguration _configuration; - public EmailSender(IOptions emailSettings) + public EmailSender(IOptions emailSettings, IConfiguration configuration) { _smtpSettings = emailSettings.Value; + _configuration = configuration; + } + + public async Task GetEmailTemplate(string templateName, Dictionary replacements) + { + string path = Path.Combine(Directory.GetCurrentDirectory(), "EmailTemplates", $"{templateName}.html"); + + if (!File.Exists(path)) + throw new FileNotFoundException("Template file not found"); + + string content = await File.ReadAllTextAsync(path); + + foreach (var item in replacements) + { + content = content.Replace($"{{{{{item.Key}}}}}", item.Value); + } + + return content; + } + + public async Task SendResetPasswordEmailOnRegister(string toEmail, string toName, string resetLink) + { + var replacements = new Dictionary + { + { "MAIL_TITLE", "New registration,Reset Your Password" }, + { "RESET_PWD_URL", resetLink }, + { "RECEIVER_NAME", toName } + }; + + string emailBody = await GetEmailTemplate("new-user-email", replacements); + + await SendEmailAsync(toEmail, "New user registration, Reset Your Password", emailBody); + } + public async Task SendResetPasswordEmail(string toEmail, string userName, string resetLink) + { + var replacements = new Dictionary + { + { "MAIL_TITLE", "Reset Your Password" }, + { "RESET_PWD_URL", resetLink } + }; + + string emailBody = await GetEmailTemplate("forgot-password", replacements); + + + await SendEmailAsync(toEmail, "Reset Your Password", emailBody); + } public async Task SendEmailAsync(string toEmail, string subject, string body) diff --git a/Marco.Pms.Services/Service/IEmailSender.cs b/Marco.Pms.Services/Service/IEmailSender.cs index a5a5754..7ede524 100644 --- a/Marco.Pms.Services/Service/IEmailSender.cs +++ b/Marco.Pms.Services/Service/IEmailSender.cs @@ -2,6 +2,9 @@ { public interface IEmailSender { + Task SendResetPasswordEmail(string toEmail, string userName, string resetLink); + Task SendResetPasswordEmailOnRegister(string toEmail, string toName, string resetLink); + Task SendEmailAsync(string toEmail, string subject, string body); } } diff --git a/Marco.Pms.Services/Service/ILoggingService.cs b/Marco.Pms.Services/Service/ILoggingService.cs new file mode 100644 index 0000000..744ab19 --- /dev/null +++ b/Marco.Pms.Services/Service/ILoggingService.cs @@ -0,0 +1,15 @@ +using Serilog.Context; + +namespace MarcoBMS.Services.Service +{ + public interface ILoggingService + { + void LogInfo(string? message, params object[]? args); + void LogWarning(string? message, params object[]? args); + void LogError(Exception? ex, string? message, params object[]? args); + + } +} + + + diff --git a/Marco.Pms.Services/Service/LoggingServices.cs b/Marco.Pms.Services/Service/LoggingServices.cs new file mode 100644 index 0000000..aec6257 --- /dev/null +++ b/Marco.Pms.Services/Service/LoggingServices.cs @@ -0,0 +1,35 @@ +using Serilog.Context; + +namespace MarcoBMS.Services.Service +{ + public class LoggingService : ILoggingService + { + private readonly ILogger _logger; + + public LoggingService(ILogger logger) + { + _logger = logger; + } + + public void LogError(Exception? ex, string? message, params object[]? args) + { + using (LogContext.PushProperty("Error", ex)) + using (LogContext.PushProperty("LogLevel", "Error")) + _logger.LogError(message, args); + } + + public void LogInfo(string? message, params object[]? args) + { + using (LogContext.PushProperty("LogLevel", "Information")) + _logger.LogInformation(message, args); + } + + public void LogWarning(string? message, params object[]? args) + { + using (LogContext.PushProperty("LogLevel", "Warning")) + _logger.LogWarning(message,args); + } + } + +} + diff --git a/Marco.Pms.Services/appsettings.json b/Marco.Pms.Services/appsettings.json index bf639e3..868c367 100644 --- a/Marco.Pms.Services/appsettings.json +++ b/Marco.Pms.Services/appsettings.json @@ -1,14 +1,75 @@ { - "Logging": { - "LogLevel": { + "Serilog": { + "Using": [ + "Serilog.Sinks.Console", + "Serilog.Sinks.MongoDB", + "Serilog.Sinks.Async" + ], + "MinimumLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } + "Override": { + "Microsoft": "Warning", + "Microsoft.EntityFrameworkCore.Database.Command": "Warning", + "Microsoft.AspNetCore.Mvc.Infrastructure": "Warning", + "Serilog.AspNetCore.RequestLoggingMiddleware": "Warning" + } + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "MongoDB", + "Args": { + "databaseUrl": "mongodb://localhost:27017/DotNetLogs", + //"databaseUrl": "mongodb://devuser:xxxxx@147.93.98.152:27017/MarcoPMS?authSource=admin", + "collectionName": "application_logs", + "batchPostingLimit": 50, + "cappedMaxSizeMb": "1024", + "cappedMaxDocuments": "1000", + "rollingInterval": "Day" + //"outputTemplate": "[{Timestamp:yyyy/MM/dd HH:mm} {Level:u3}] {SourceContext}:{NewLine} {Message:lj}{Exception}{NewLine}" + } + }, + { + "Name": "File", + "Args": { + "path": "logs/myapp-.log", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level:u3}] {Message:lj}{NewLine}{Exception}", + "fileSizeLimitBytes": 1073741824, // 1 GB + "retainedFileCountLimit": 100, // Retain 100 files + "buffered": true, // use async logging + "flushToDiskInterval": "00:00:30" // flush every 30 seconds + } + }, + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:yyyy/MM/dd HH:mm} {Level:u3}] {SourceContext}:{NewLine} {Message:lj}{NewLine}{Properties:j}{Exception}{NewLine}" + } + } + ] + } + } + + ], + "Enrich": [ + "FromLogContext", + "WithMachineName", + "WithThreadId" + ] }, + "ConnectionStrings": { // "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci", - //"DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;Database=MarcoBMS1", - "DefaultConnectionString": "Server=147.93.98.152;User ID=root;Password=MySqlUser@123$;Database=MarcoBMS1" + "DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;Database=MarcoBMS1", + // "DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1" + }, + "AppSettings": { + "WebFrontendUrl": "http://localhost:5173", + "ImagesBaseUrl": "http://localhost:5173" }, "AllowedHosts": "*", "Jwt": { diff --git a/Marco.Pms.Services/wwwroot/logos/marco-aiot-tech-logo.jpg b/Marco.Pms.Services/wwwroot/logos/marco-aiot-tech-logo.jpg new file mode 100644 index 0000000..0ca11bf Binary files /dev/null and b/Marco.Pms.Services/wwwroot/logos/marco-aiot-tech-logo.jpg differ diff --git a/Marco.Pms.Utility/DataConversionUtil.cs b/Marco.Pms.Utility/DataConversionUtil.cs index 997fb67..191eb67 100644 --- a/Marco.Pms.Utility/DataConversionUtil.cs +++ b/Marco.Pms.Utility/DataConversionUtil.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MarcoBMS.Utility +namespace Marco.Pms.Utility { public static class ParentToChildClassMapper { diff --git a/Marco.Pms.Utility/EmailSender.cs b/Marco.Pms.Utility/EmailSender.cs index 60d85e3..26f5e74 100644 --- a/Marco.Pms.Utility/EmailSender.cs +++ b/Marco.Pms.Utility/EmailSender.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Identity.UI.Services; -namespace MarcoBMS.Utility +namespace Marco.Pms.Utility { public class EmailSender : IEmailSender { diff --git a/Marco.Pms.Utility/SessionUtil.cs b/Marco.Pms.Utility/SessionUtil.cs index e5ac2e5..5083419 100644 --- a/Marco.Pms.Utility/SessionUtil.cs +++ b/Marco.Pms.Utility/SessionUtil.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MarcoBMS.Utility +namespace Marco.Pms.Utility { public class SessionUtil { diff --git a/Marco.Pms.Utility/enum.cs b/Marco.Pms.Utility/enum.cs index b8e821c..162a163 100644 --- a/Marco.Pms.Utility/enum.cs +++ b/Marco.Pms.Utility/enum.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MarcoBMS.Utility +namespace Marco.Pms.Utility { public enum APP_ROLES {