Resolve merge conflict with rebase
This commit is contained in:
commit
cb370b97ea
29
Marco.Pms.Model/Dtos/Tenant/CreateTenantDto.cs
Normal file
29
Marco.Pms.Model/Dtos/Tenant/CreateTenantDto.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Dtos.Tenant
|
||||||
|
{
|
||||||
|
public class CreateTenantDto
|
||||||
|
{
|
||||||
|
//[Required]
|
||||||
|
//public string Username { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[EmailAddress]
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MinLength(6)]
|
||||||
|
[RegularExpression(@"^(?=.*[^a-zA-Z0-9])(?=.*\d)(?=.*[A-Z]).+$", ErrorMessage = "Passwords must have at least one non-alphanumeric character, at least one digit ('0'-'9'), and at least one uppercase ('A'-'Z').")]
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string OrganizatioinName { get; set; }
|
||||||
|
public string? About { get; set; }
|
||||||
|
public string? OragnizationSize { get; set; }
|
||||||
|
public int IndustryId { get; set; }
|
||||||
|
public string Website { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string ContactNumber { get; set; }
|
||||||
|
public DateTime OnBoardingDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
namespace Marco.Pms.Model.Entitlements
|
||||||
using System.ComponentModel;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
|
||||||
{
|
{
|
||||||
public class ApplicationRole
|
public class ApplicationRole
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using System.ComponentModel;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
namespace Marco.Pms.Model.Entitlements
|
||||||
{
|
{
|
||||||
public class ApplicationUser : IdentityUser
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
[Required]
|
//[Required]
|
||||||
public string Role { get; set; } // e.g. Admin, SiteManager, SkilledWorker, etc.
|
// public string Role { get; set; } // e.g. Admin, SiteManager, SkilledWorker, etc.
|
||||||
|
|
||||||
|
|
||||||
[DisplayName("TenantId")]
|
[DisplayName("TenantId")]
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace Marco.Pms.Model.Entitlements
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
|
||||||
{
|
{
|
||||||
public class Tenant
|
public class Tenant
|
||||||
{
|
{
|
||||||
@ -14,6 +8,9 @@ namespace Marco.Pms.Model.Entitlements
|
|||||||
public string DomainName { get; set; }
|
public string DomainName { get; set; }
|
||||||
public string ContactName { get; set; }
|
public string ContactName { get; set; }
|
||||||
public string ContactNumber { get; set; }
|
public string ContactNumber { get; set; }
|
||||||
|
|
||||||
|
//public string? OragnizationSize { get; set; }
|
||||||
|
//public int IndustryId { get; set; }
|
||||||
public DateTime OnBoardingDate { get; set; }
|
public DateTime OnBoardingDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
using Marco.Pms.Model.Projects;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
namespace Marco.Pms.Model.Entitlements
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
namespace Marco.Pms.Model.Entitlements
|
||||||
{
|
{
|
||||||
|
37
Marco.Pms.Model/Mapper/TenantMapper.cs
Normal file
37
Marco.Pms.Model/Mapper/TenantMapper.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using Marco.Pms.Model.Dtos.Tenant;
|
||||||
|
using Marco.Pms.Model.Entitlements;
|
||||||
|
using Marco.Pms.Model.ViewModels.Tenant;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Mapper
|
||||||
|
{
|
||||||
|
public static class TenantMapper
|
||||||
|
{
|
||||||
|
public static Tenant CreateDtoToTenant(this CreateTenantDto createTenant)
|
||||||
|
{
|
||||||
|
return new Tenant
|
||||||
|
{
|
||||||
|
Name = createTenant.OrganizatioinName,
|
||||||
|
Description = createTenant.About,
|
||||||
|
DomainName = createTenant.Website,
|
||||||
|
ContactName = createTenant.Name,
|
||||||
|
//OragnizationSize = OragnizationSize,
|
||||||
|
//IndustryId = IndustryId,
|
||||||
|
ContactNumber = createTenant.ContactNumber,
|
||||||
|
OnBoardingDate = createTenant.OnBoardingDate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static TenantVM ToTenantVMFromTenant(this Tenant tenant)
|
||||||
|
{
|
||||||
|
return new TenantVM
|
||||||
|
{
|
||||||
|
OrganizationName = tenant.Name,
|
||||||
|
About = tenant.Description,
|
||||||
|
Website = tenant.DomainName,
|
||||||
|
Name = tenant.ContactName,
|
||||||
|
//OragnizationSize = OragnizationSize,
|
||||||
|
ContactNumber = tenant.ContactNumber,
|
||||||
|
OnBoardingDate = tenant.OnBoardingDate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Marco.Pms.Model/Utilities/RolesConfiguration.cs
Normal file
16
Marco.Pms.Model/Utilities/RolesConfiguration.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.Utilities
|
||||||
|
{
|
||||||
|
public class RoleConfiguration
|
||||||
|
{
|
||||||
|
public string JobRoleName { get; set; }
|
||||||
|
public string JobRoleDescription { get; set; }
|
||||||
|
public string RoleName { get; set; }
|
||||||
|
public string RoleDescription { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
Marco.Pms.Model/ViewModels/Tenant/TenantVM.cs
Normal file
21
Marco.Pms.Model/ViewModels/Tenant/TenantVM.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.ViewModels.Tenant
|
||||||
|
{
|
||||||
|
public class TenantVM
|
||||||
|
{
|
||||||
|
public string OrganizationName { get; set; }
|
||||||
|
public string About { get; set; }
|
||||||
|
public string Website { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string ContactNumber { get; set; }
|
||||||
|
|
||||||
|
//public string? OragnizationSize { get; set; }
|
||||||
|
//public int IndustryId { get; set; }
|
||||||
|
public DateTime OnBoardingDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -217,7 +217,10 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID &&
|
Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID &&
|
||||||
a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ;
|
a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId);
|
||||||
|
|
||||||
|
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (attendance != null)
|
if (attendance != null)
|
||||||
@ -236,13 +239,13 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
//string timeString = "10:30 PM"; // Format: "hh:mm tt"
|
//string timeString = "10:30 PM"; // Format: "hh:mm tt"
|
||||||
|
|
||||||
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
//DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||||
|
|
||||||
attendance.OutTime = finalDateTime;
|
attendance.OutTime = finalDateTime;
|
||||||
}
|
}
|
||||||
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE)
|
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE)
|
||||||
{
|
{
|
||||||
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
//DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||||
|
|
||||||
attendance.OutTime = finalDateTime;
|
attendance.OutTime = finalDateTime;
|
||||||
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
|
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
|
||||||
@ -277,7 +280,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
attendance.Date = DateTime.UtcNow;
|
attendance.Date = DateTime.UtcNow;
|
||||||
|
|
||||||
|
|
||||||
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
//DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||||
|
|
||||||
attendance.InTime = finalDateTime;
|
attendance.InTime = finalDateTime;
|
||||||
attendance.OutTime = null;
|
attendance.OutTime = null;
|
||||||
@ -295,7 +298,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
AttendanceId = attendance.Id, // Use existing or new AttendanceId
|
AttendanceId = attendance.Id, // Use existing or new AttendanceId
|
||||||
Activity = attendance.Activity,
|
Activity = attendance.Activity,
|
||||||
|
|
||||||
ActivityTime = recordAttendanceDot.Date,
|
ActivityTime = finalDateTime,
|
||||||
|
//ActivityTime = recordAttendanceDot.Date,
|
||||||
Comment = recordAttendanceDot.Comment,
|
Comment = recordAttendanceDot.Comment,
|
||||||
EmployeeID = recordAttendanceDot.EmployeeID,
|
EmployeeID = recordAttendanceDot.EmployeeID,
|
||||||
Latitude = recordAttendanceDot.Latitude,
|
Latitude = recordAttendanceDot.Latitude,
|
||||||
@ -303,7 +307,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
TenantId = TenantId,
|
TenantId = TenantId,
|
||||||
UpdatedBy = GetUserId(),
|
UpdatedBy = GetUserId(),
|
||||||
UpdatedOn = DateTime.UtcNow
|
UpdatedOn = recordAttendanceDot.Date
|
||||||
|
//UpdatedOn = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
//if (recordAttendanceDot.Image != null && recordAttendanceDot.Image.Count > 0)
|
//if (recordAttendanceDot.Image != null && recordAttendanceDot.Image.Count > 0)
|
||||||
//{
|
//{
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
using Marco.Pms.Model.Authentication;
|
using System.Net;
|
||||||
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Dtos;
|
using Marco.Pms.Model.Dtos;
|
||||||
using Marco.Pms.Model.Dtos.Util;
|
using Marco.Pms.Model.Dtos.Util;
|
||||||
using Marco.Pms.Model.Employees;
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.Utilities;
|
using Marco.Pms.Model.Utilities;
|
||||||
using Marco.Pms.Model.ViewModels.Employee;
|
|
||||||
using MarcoBMS.Services.Helpers;
|
using MarcoBMS.Services.Helpers;
|
||||||
using MarcoBMS.Services.Service;
|
using MarcoBMS.Services.Service;
|
||||||
using Microsoft.AspNetCore.Cors;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.Data;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Controllers
|
namespace MarcoBMS.Services.Controllers
|
||||||
{
|
{
|
||||||
|
173
Marco.Pms.Services/Controllers/TenantController.cs
Normal file
173
Marco.Pms.Services/Controllers/TenantController.cs
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Model.Dtos.Tenant;
|
||||||
|
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.Tenant;
|
||||||
|
using MarcoBMS.Services.Service;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Services.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TenantController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly string jsonString = System.IO.File.ReadAllText("Data/RolesCofiguration.json");
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly UserManager<IdentityUser> _userManager;
|
||||||
|
private readonly ILoggingService _logger;
|
||||||
|
public TenantController(ApplicationDbContext context,UserManager<IdentityUser> userManager, ILoggingService logger)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_userManager = userManager;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> CreateTenant([FromForm] CreateTenantDto createTenantDto)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return BadRequest(ModelState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _userManager.FindByEmailAsync(createTenantDto.Email) != null && await _context.Tenants.FirstOrDefaultAsync(t => t.Name == createTenantDto.OrganizatioinName) != null)
|
||||||
|
{
|
||||||
|
return BadRequest("Tenant Already Exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
Tenant newTenant = createTenantDto.CreateDtoToTenant();
|
||||||
|
_context.Tenants.Add(newTenant);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
//Tenant? tenant = await _context.Tenants.FirstOrDefaultAsync(t => t.Name == newTenant.Name);
|
||||||
|
|
||||||
|
if (newTenant != null)
|
||||||
|
{
|
||||||
|
RoleConfiguration settings = JsonSerializer.Deserialize<RoleConfiguration>(jsonString);
|
||||||
|
var TenantId = newTenant.Id;
|
||||||
|
JobRole jobRole = new JobRole
|
||||||
|
{
|
||||||
|
Name = settings.JobRoleName,
|
||||||
|
Description = settings.JobRoleDescription,
|
||||||
|
TenantId = TenantId
|
||||||
|
};
|
||||||
|
|
||||||
|
ApplicationRole role = new ApplicationRole
|
||||||
|
{
|
||||||
|
Role = settings.RoleName,
|
||||||
|
Description = settings.RoleDescription,
|
||||||
|
TenantId = TenantId
|
||||||
|
};
|
||||||
|
|
||||||
|
_context.JobRoles.Add(jobRole);
|
||||||
|
_context.ApplicationRoles.Add(role);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
|
List<FeaturePermission> permissions = await _context.FeaturePermissions.AsNoTracking().ToListAsync();
|
||||||
|
List<RolePermissionMappings> rolePermissionMappings = new List<RolePermissionMappings>();
|
||||||
|
|
||||||
|
foreach (var permission in permissions)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
rolePermissionMappings.Add(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
_context.RolePermissionMappings.AddRange(rolePermissionMappings);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var user = new ApplicationUser
|
||||||
|
{
|
||||||
|
UserName = createTenantDto.Email,
|
||||||
|
Email = createTenantDto.Email,
|
||||||
|
TenantId = TenantId,
|
||||||
|
IsRootUser = true,
|
||||||
|
EmailConfirmed = true
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _userManager.CreateAsync(user, createTenantDto.Password);
|
||||||
|
if (result.Succeeded)
|
||||||
|
{
|
||||||
|
Employee newEmployee = CreateTenantDtoToEmployee(createTenantDto, TenantId, user.Id,jobRole.Id);
|
||||||
|
_context.Employees.Add(newEmployee);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var employeeRoleMapping = new EmployeeRoleMapping
|
||||||
|
{
|
||||||
|
EmployeeId = newEmployee.Id,
|
||||||
|
RoleId = role.Id,
|
||||||
|
TenantId = TenantId,
|
||||||
|
IsEnabled = true
|
||||||
|
};
|
||||||
|
_context.EmployeeRoleMappings.Add(employeeRoleMapping);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(result.Succeeded, "Tenant created successfully.", 200));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Log the errors for debugging
|
||||||
|
foreach (var error in result.Errors)
|
||||||
|
{
|
||||||
|
// Log error.Description
|
||||||
|
_logger.LogError("{Error}",error.Description);
|
||||||
|
}
|
||||||
|
return BadRequest("Failed to create the root user.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BadRequest("Falied to create Tenant");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("profile/{tenantId}")]
|
||||||
|
public async Task<IActionResult> GetTenantProfile(int tenantId)
|
||||||
|
{
|
||||||
|
if (tenantId <= 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Tenant Id is required and must be greater than zero.");
|
||||||
|
}
|
||||||
|
var tenant = await _context.Tenants.FirstOrDefaultAsync(t => t.Id == tenantId);
|
||||||
|
if (tenant == null)
|
||||||
|
{
|
||||||
|
return NotFound("Tenant Not Found");
|
||||||
|
}
|
||||||
|
TenantVM tenantVM = tenant.ToTenantVMFromTenant();
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(tenantVM, "Tenant Profile.", 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Employee CreateTenantDtoToEmployee(CreateTenantDto model, int TenantId, string? ApplicationUserId,int jobRoleId)
|
||||||
|
{
|
||||||
|
return new Employee
|
||||||
|
{
|
||||||
|
ApplicationUserId = ApplicationUserId,
|
||||||
|
FirstName = model.Name,
|
||||||
|
LastName = "",
|
||||||
|
Email = model.Email,
|
||||||
|
TenantId = TenantId,
|
||||||
|
CurrentAddress = "",
|
||||||
|
BirthDate = DateTime.UtcNow,
|
||||||
|
EmergencyPhoneNumber = "",
|
||||||
|
EmergencyContactPerson = "",
|
||||||
|
AadharNumber = "",
|
||||||
|
Gender = "",
|
||||||
|
MiddleName = "",
|
||||||
|
PanNumber = "",
|
||||||
|
PeramnentAddress = "",
|
||||||
|
PhoneNumber = "",
|
||||||
|
Photo = null, // GetFileDetails(model.Photo).Result.FileData,
|
||||||
|
JobRoleId = jobRoleId,
|
||||||
|
JoiningDate = DateTime.UtcNow,
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
6
Marco.Pms.Services/Data/RolesCofiguration.json
Normal file
6
Marco.Pms.Services/Data/RolesCofiguration.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"JobRoleName": "Admin",
|
||||||
|
"JobRoleDescription": "Admin",
|
||||||
|
"RoleName": "SuperUser",
|
||||||
|
"RoleDescription": "SuperUser"
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
using Marco.Pms.Model.Dtos.Employees;
|
using System.Security.Claims;
|
||||||
using Marco.Pms.Model.Entitlements;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using System.Security.Claims;
|
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Helpers
|
namespace MarcoBMS.Services.Helpers
|
||||||
{
|
{
|
||||||
@ -29,6 +27,7 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
if (string.IsNullOrEmpty(userId))
|
if (string.IsNullOrEmpty(userId))
|
||||||
return null;
|
return null;
|
||||||
var user = await _userManager.FindByEmailAsync(userId);
|
var user = await _userManager.FindByEmailAsync(userId);
|
||||||
|
//var user = await _userManager.FindByNameAsync(userId); // For fetching user using username
|
||||||
return user; //await _userManager.FindByIdAsync(userId);
|
return user; //await _userManager.FindByIdAsync(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace MarcoBMS.Services.Middleware
|
|||||||
|
|
||||||
|
|
||||||
using (LogContext.PushProperty("TenantId", tenantId))
|
using (LogContext.PushProperty("TenantId", tenantId))
|
||||||
using (LogContext.PushProperty("TraceId", context.TraceIdentifier))
|
//using (LogContext.PushProperty("TraceId", context.TraceIdentifier))
|
||||||
using (LogContext.PushProperty("UserAgent", request.Headers["User-Agent"].ToString()))
|
using (LogContext.PushProperty("UserAgent", request.Headers["User-Agent"].ToString()))
|
||||||
using (LogContext.PushProperty("HttpMethod", request.Method))
|
using (LogContext.PushProperty("HttpMethod", request.Method))
|
||||||
using (LogContext.PushProperty("Timestamp", DateTime.UtcNow))
|
using (LogContext.PushProperty("Timestamp", DateTime.UtcNow))
|
||||||
@ -44,7 +44,7 @@ namespace MarcoBMS.Services.Middleware
|
|||||||
using (LogContext.PushProperty("StatusCode", response.StatusCode.ToString()))
|
using (LogContext.PushProperty("StatusCode", response.StatusCode.ToString()))
|
||||||
using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds))
|
using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds))
|
||||||
using (LogContext.PushProperty("LogLevel", "Information"))
|
using (LogContext.PushProperty("LogLevel", "Information"))
|
||||||
_logger.LogInformation("HTTP {method} {path} responded {statusCode} in {timeTaken} ms", request.Method,request.Path, response.StatusCode.ToString(),stopwatch.ElapsedMilliseconds);
|
_logger.LogInformation("HTTP {HttpMethod} {RequestPath} responded {statusCode} in {ResponseTimeMs} ms", request.Method,request.Path, response.StatusCode.ToString(),stopwatch.ElapsedMilliseconds);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ namespace MarcoBMS.Services.Middleware
|
|||||||
using (LogContext.PushProperty("StatusCode", "500"))
|
using (LogContext.PushProperty("StatusCode", "500"))
|
||||||
using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds))
|
using (LogContext.PushProperty("ResponseTimeMs", stopwatch.ElapsedMilliseconds))
|
||||||
using (LogContext.PushProperty("LogLevel", "Error"))
|
using (LogContext.PushProperty("LogLevel", "Error"))
|
||||||
_logger.LogError("API Error{error}", ex.Message);
|
_logger.LogError("API Error: {Error}", ex.Message);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using Microsoft.OpenApi.Models;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
Serilog.Debugging.SelfLog.Enable(Console.Error);
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -166,9 +167,13 @@ app.UseCors("Policy");
|
|||||||
|
|
||||||
app.UseStaticFiles(); // Enables serving static files
|
app.UseStaticFiles(); // Enables serving static files
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
//app.UseSerilogRequestLogging(); // This is Default Serilog Logging Middleware we are not using this because we're using custom logging middleware
|
//app.UseSerilogRequestLogging(); // This is Default Serilog Logging Middleware we are not using this because we're using custom logging middleware
|
||||||
|
|
||||||
|
|
||||||
|
=======
|
||||||
|
//app.UseSerilogRequestLogging(); // Log HTTP requests
|
||||||
|
>>>>>>> a4156153ff6618675abf0590395745816019a973
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||||
app.UseMiddleware<TenantMiddleware>();
|
app.UseMiddleware<TenantMiddleware>();
|
||||||
|
@ -6,7 +6,7 @@ namespace MarcoBMS.Services.Service
|
|||||||
{
|
{
|
||||||
void LogInfo(string? message, params object[]? args);
|
void LogInfo(string? message, params object[]? args);
|
||||||
void LogWarning(string? message, params object[]? args);
|
void LogWarning(string? message, params object[]? args);
|
||||||
void LogError(Exception? ex, string? message, params object[]? args);
|
void LogError(string? message, params object[]? args);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,8 @@ namespace MarcoBMS.Services.Service
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogError(Exception? ex, string? message, params object[]? args)
|
public void LogError(string? message, params object[]? args)
|
||||||
{
|
{
|
||||||
using (LogContext.PushProperty("Error", ex))
|
|
||||||
using (LogContext.PushProperty("LogLevel", "Error"))
|
using (LogContext.PushProperty("LogLevel", "Error"))
|
||||||
_logger.LogError(message, args);
|
_logger.LogError(message, args);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
using Marco.Pms.DataAccess.Data;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
using Marco.Pms.Model.Authentication;
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Entitlements;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using SharpCompress.Common;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Service
|
namespace MarcoBMS.Services.Service
|
||||||
|
@ -21,16 +21,16 @@
|
|||||||
"configure": [
|
"configure": [
|
||||||
{
|
{
|
||||||
"Name": "MongoDB",
|
"Name": "MongoDB",
|
||||||
"Args": {
|
"Args": {
|
||||||
"databaseUrl": "mongodb://localhost:27017/DotNetLogs",
|
"databaseUrl": "mongodb+srv://ashutoshnehete:OL1Cy0pTQaGn4hcP@marcopms.m32uppx.mongodb.net/MarcoPMS?retryWrites=true&w=majority",
|
||||||
//"databaseUrl": "mongodb://devuser:xxxxx@147.93.98.152:27017/MarcoPMS?authSource=admin",
|
//"databaseUrl": "mongodb://devuser:xxxxx@147.93.98.152:27017/MarcoPMS?authSource=admin",
|
||||||
"collectionName": "application_logs",
|
"collectionName": "application_logs",
|
||||||
"batchPostingLimit": 50,
|
"batchPostingLimit": 50,
|
||||||
"cappedMaxSizeMb": "1024",
|
"cappedMaxSizeMb": "1024",
|
||||||
"cappedMaxDocuments": "1000",
|
"cappedMaxDocuments": "1000",
|
||||||
"rollingInterval": "Day"
|
"rollingInterval": "Day"
|
||||||
//"outputTemplate": "[{Timestamp:yyyy/MM/dd HH:mm} {Level:u3}] {SourceContext}:{NewLine} {Message:lj}{Exception}{NewLine}"
|
//"outputTemplate": "[{Timestamp:yyyy/MM/dd HH:mm} {Level:u3}] {SourceContext}:{NewLine} {Message:lj}{Exception}{NewLine}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "File",
|
"Name": "File",
|
||||||
@ -64,8 +64,13 @@
|
|||||||
|
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
||||||
|
<<<<<<< HEAD
|
||||||
//"DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;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"
|
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@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"
|
||||||
|
>>>>>>> a4156153ff6618675abf0590395745816019a973
|
||||||
},
|
},
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"WebFrontendUrl": "http://localhost:5173",
|
"WebFrontendUrl": "http://localhost:5173",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user