Added Currency in subscription list VM
This commit is contained in:
parent
cbcae9fb57
commit
6b4e229f6b
@ -25,7 +25,11 @@ namespace Marco.Pms.Model.ViewModels.Tenant
|
|||||||
public bool IsSuperTenant { get; set; } = false;
|
public bool IsSuperTenant { get; set; } = false;
|
||||||
public int ActiveEmployees { get; set; }
|
public int ActiveEmployees { get; set; }
|
||||||
public int InActiveEmployees { get; set; }
|
public int InActiveEmployees { get; set; }
|
||||||
public object? Projects { get; set; }
|
public int? ActiveProjects { get; set; }
|
||||||
|
public int? InProgressProjects { get; set; }
|
||||||
|
public int? OnHoldProjects { get; set; }
|
||||||
|
public int? InActiveProjects { get; set; }
|
||||||
|
public int? CompletedProjects { get; set; }
|
||||||
public DateTime? ExpiryDate { get; set; }
|
public DateTime? ExpiryDate { get; set; }
|
||||||
public DateTime? NextBillingDate { get; set; }
|
public DateTime? NextBillingDate { get; set; }
|
||||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||||
|
@ -39,7 +39,13 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
private readonly UserHelper _userHelper;
|
private readonly UserHelper _userHelper;
|
||||||
private readonly FeatureDetailsHelper _featureDetailsHelper;
|
private readonly FeatureDetailsHelper _featureDetailsHelper;
|
||||||
|
|
||||||
private readonly static Guid activeStatus = Guid.Parse("62b05792-5115-4f99-8ff5-e8374859b191");
|
private readonly static Guid projectActiveStatus = Guid.Parse("b74da4c2-d07e-46f2-9919-e75e49b12731");
|
||||||
|
private readonly static Guid projectInProgressStatus = Guid.Parse("cdad86aa-8a56-4ff4-b633-9c629057dfef");
|
||||||
|
private readonly static Guid projectOnHoldStatus = Guid.Parse("603e994b-a27f-4e5d-a251-f3d69b0498ba");
|
||||||
|
private readonly static Guid projectInActiveStatus = Guid.Parse("ef1c356e-0fe0-42df-a5d3-8daee355492d");
|
||||||
|
private readonly static Guid projectCompletedStatus = Guid.Parse("33deaef9-9af1-4f2a-b443-681ea0d04f81");
|
||||||
|
|
||||||
|
private readonly static Guid tenantActiveStatus = Guid.Parse("62b05792-5115-4f99-8ff5-e8374859b191");
|
||||||
private readonly static Guid activePlanStatus = Guid.Parse("cd3a68ea-41fd-42f0-bd0c-c871c7337727");
|
private readonly static Guid activePlanStatus = Guid.Parse("cd3a68ea-41fd-42f0-bd0c-c871c7337727");
|
||||||
private readonly static Guid EmployeeFeatureId = Guid.Parse("81ab8a87-8ccd-4015-a917-0627cee6a100");
|
private readonly static Guid EmployeeFeatureId = Guid.Parse("81ab8a87-8ccd-4015-a917-0627cee6a100");
|
||||||
private readonly static string AdminRoleName = "Admin";
|
private readonly static string AdminRoleName = "Admin";
|
||||||
@ -270,7 +276,11 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
var planTask = Task.Run(async () =>
|
var planTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await using var _dbContext = await _dbContextFactory.CreateDbContextAsync();
|
await using var _dbContext = await _dbContextFactory.CreateDbContextAsync();
|
||||||
return await _dbContext.TenantSubscriptions.AsNoTracking().Where(ts => ts.TenantId == tenant.Id && !ts.IsCancelled && ts.Plan != null).FirstOrDefaultAsync();
|
return await _dbContext.TenantSubscriptions
|
||||||
|
.Include(ts => ts.Plan).ThenInclude(sp => sp!.Plan)
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(ts => ts.TenantId == tenant.Id && ts.Plan != null)
|
||||||
|
.OrderBy(ts => ts.CreatedBy).ToListAsync();
|
||||||
});
|
});
|
||||||
var projectTask = Task.Run(async () =>
|
var projectTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@ -279,12 +289,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
.Include(p => p.ProjectStatus)
|
.Include(p => p.ProjectStatus)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(p => p.TenantId == tenant.Id)
|
.Where(p => p.TenantId == tenant.Id)
|
||||||
.GroupBy(p => p.ProjectStatusId)
|
|
||||||
.Select(g => new
|
|
||||||
{
|
|
||||||
Status = g.Where(p => p.ProjectStatus != null && p.ProjectStatus.Id == g.Key).Select(p => p.ProjectStatus).FirstOrDefault(),
|
|
||||||
ProjectsCount = g.Where(p => p.ProjectStatusId == g.Key).Count()
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -292,25 +296,30 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
|
|
||||||
var employees = employeeTask.Result;
|
var employees = employeeTask.Result;
|
||||||
var projects = projectTask.Result;
|
var projects = projectTask.Result;
|
||||||
var currentPlan = planTask.Result;
|
var plans = planTask.Result;
|
||||||
var createdBy = createdByTask.Result;
|
var createdBy = createdByTask.Result;
|
||||||
|
|
||||||
var activeEmployeesCount = employees.Where(e => e.IsActive).Count();
|
var activeEmployeesCount = employees.Where(e => e.IsActive).Count();
|
||||||
var inActiveEmployeesCount = employees.Where(e => !e.IsActive).Count();
|
var inActiveEmployeesCount = employees.Where(e => !e.IsActive).Count();
|
||||||
|
|
||||||
|
var currentPlan = plans.FirstOrDefault(ts => !ts.IsCancelled);
|
||||||
var expiryDate = currentPlan?.EndDate;
|
var expiryDate = currentPlan?.EndDate;
|
||||||
var nextBillingDate = currentPlan?.NextBillingDate;
|
var nextBillingDate = currentPlan?.NextBillingDate;
|
||||||
|
|
||||||
var response = _mapper.Map<TenantDetailsVM>(tenant);
|
var response = _mapper.Map<TenantDetailsVM>(tenant);
|
||||||
response.ActiveEmployees = activeEmployeesCount;
|
response.ActiveEmployees = activeEmployeesCount;
|
||||||
response.InActiveEmployees = inActiveEmployeesCount;
|
response.InActiveEmployees = inActiveEmployeesCount;
|
||||||
response.Projects = projects;
|
response.ActiveProjects = projects.Where(p => p.ProjectStatusId == projectActiveStatus).Count();
|
||||||
|
response.InProgressProjects = projects.Where(p => p.ProjectStatusId == projectInProgressStatus).Count();
|
||||||
|
response.OnHoldProjects = projects.Where(p => p.ProjectStatusId == projectOnHoldStatus).Count();
|
||||||
|
response.InActiveProjects = projects.Where(p => p.ProjectStatusId == projectInActiveStatus).Count();
|
||||||
|
response.CompletedProjects = projects.Where(p => p.ProjectStatusId == projectCompletedStatus).Count();
|
||||||
response.ExpiryDate = expiryDate;
|
response.ExpiryDate = expiryDate;
|
||||||
response.NextBillingDate = nextBillingDate;
|
response.NextBillingDate = nextBillingDate;
|
||||||
response.CreatedBy = createdBy;
|
response.CreatedBy = createdBy;
|
||||||
|
|
||||||
|
|
||||||
return Ok();
|
return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant profile fetched successfully", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST api/<TenantController>
|
// POST api/<TenantController>
|
||||||
@ -403,7 +412,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
|
|
||||||
var tenant = _mapper.Map<Tenant>(model);
|
var tenant = _mapper.Map<Tenant>(model);
|
||||||
|
|
||||||
tenant.TenantStatusId = activeStatus;
|
tenant.TenantStatusId = tenantActiveStatus;
|
||||||
tenant.CreatedById = loggedInEmployee.Id;
|
tenant.CreatedById = loggedInEmployee.Id;
|
||||||
tenant.IsSuperTenant = false;
|
tenant.IsSuperTenant = false;
|
||||||
|
|
||||||
@ -1066,7 +1075,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
await using var _context = await _dbContextFactory.CreateDbContextAsync();
|
await using var _context = await _dbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
// Load subscription plans with optional frequency filtering
|
// Load subscription plans with optional frequency filtering
|
||||||
IQueryable<SubscriptionPlanDetails> query = _context.SubscriptionPlanDetails.Include(sp => sp.Plan);
|
IQueryable<SubscriptionPlanDetails> query = _context.SubscriptionPlanDetails.Include(sp => sp.Plan).Include(sp => sp.Currency);
|
||||||
|
|
||||||
if (frequency.HasValue)
|
if (frequency.HasValue)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user