Compare commits
No commits in common. "a4156153ff6618675abf0590395745816019a973" and "dca6414a59a980524fa1d9a75e27bd3ff510e51e" have entirely different histories.
a4156153ff
...
dca6414a59
@ -1,6 +1,5 @@
|
|||||||
using Marco.Pms.Model.Dtos.Tenant;
|
using Marco.Pms.Model.Dtos.Tenant;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.ViewModels.Tenant;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Mapper
|
namespace Marco.Pms.Model.Mapper
|
||||||
{
|
{
|
||||||
@ -20,18 +19,6 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
OnBoardingDate = createTenant.OnBoardingDate,
|
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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +1,18 @@
|
|||||||
using System.Net;
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Authentication;
|
|
||||||
using Marco.Pms.Model.Dtos;
|
using Marco.Pms.Model.Dtos;
|
||||||
using Marco.Pms.Model.Dtos.Util;
|
using Marco.Pms.Model.Dtos.Util;
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,6 @@ using Marco.Pms.Model.Employees;
|
|||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.Mapper;
|
using Marco.Pms.Model.Mapper;
|
||||||
using Marco.Pms.Model.Utilities;
|
using Marco.Pms.Model.Utilities;
|
||||||
using Marco.Pms.Model.ViewModels.Tenant;
|
|
||||||
using MarcoBMS.Services.Service;
|
using MarcoBMS.Services.Service;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -56,6 +55,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
Description = settings.JobRoleDescription,
|
Description = settings.JobRoleDescription,
|
||||||
TenantId = TenantId
|
TenantId = TenantId
|
||||||
};
|
};
|
||||||
|
var existingJobRole = await _context.JobRoles.AsNoTracking().FirstOrDefaultAsync(r => r.Name == settings.JobRoleName);
|
||||||
|
|
||||||
ApplicationRole role = new ApplicationRole
|
ApplicationRole role = new ApplicationRole
|
||||||
{
|
{
|
||||||
@ -63,11 +63,27 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
Description = settings.RoleDescription,
|
Description = settings.RoleDescription,
|
||||||
TenantId = TenantId
|
TenantId = TenantId
|
||||||
};
|
};
|
||||||
|
var existingRole = await _context.ApplicationRoles.AsNoTracking().FirstOrDefaultAsync(r => r.Role == settings.RoleName);
|
||||||
|
|
||||||
|
if (existingJobRole == null)
|
||||||
|
{
|
||||||
_context.JobRoles.Add(jobRole);
|
_context.JobRoles.Add(jobRole);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jobRole = existingJobRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingRole == null)
|
||||||
|
{
|
||||||
_context.ApplicationRoles.Add(role);
|
_context.ApplicationRoles.Add(role);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
role = existingRole;
|
||||||
|
}
|
||||||
|
|
||||||
List<FeaturePermission> permissions = await _context.FeaturePermissions.AsNoTracking().ToListAsync();
|
List<FeaturePermission> permissions = await _context.FeaturePermissions.AsNoTracking().ToListAsync();
|
||||||
List<RolePermissionMappings> rolePermissionMappings = new List<RolePermissionMappings>();
|
List<RolePermissionMappings> rolePermissionMappings = new List<RolePermissionMappings>();
|
||||||
@ -108,7 +124,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
};
|
};
|
||||||
_context.EmployeeRoleMappings.Add(employeeRoleMapping);
|
_context.EmployeeRoleMappings.Add(employeeRoleMapping);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(result.Succeeded, "Tenant created successfully.", 200));
|
return Ok(newEmployee);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -124,23 +140,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return BadRequest("Falied to create Tenant");
|
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)
|
private static Employee CreateTenantDtoToEmployee(CreateTenantDto model, int TenantId, string? ApplicationUserId,int jobRoleId)
|
||||||
{
|
{
|
||||||
return new Employee
|
return new Employee
|
||||||
|
@ -64,8 +64,9 @@
|
|||||||
|
|
||||||
"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",
|
||||||
"DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;Database=MarcoBMS1",
|
//"DefaultConnectionString": "Server=localhost;port=3306;User ID=root;Password=Ashutosh;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"
|
||||||
},
|
},
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"WebFrontendUrl": "http://localhost:5173",
|
"WebFrontendUrl": "http://localhost:5173",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user