Spaces:
Sleeping
Sleeping
Commit ·
0a579ad
1
Parent(s): 67d4c53
fix: treat null/empty SubscriptionTier as Free tier in all limit checks
Browse files
FlowAPI.Application/Services/GraphService.cs
CHANGED
|
@@ -144,7 +144,10 @@ namespace FlowAPI.Application.Services
|
|
| 144 |
var user = await _userRepo.GetByIdAsync(currentUserId);
|
| 145 |
if (user == null) throw new Exception("User not found.");
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
{
|
| 149 |
var ownedGraphsCount = (await _repo.GetAllByUserIdAsync(currentUserId)).Count();
|
| 150 |
if (ownedGraphsCount >= 3)
|
|
@@ -306,7 +309,10 @@ namespace FlowAPI.Application.Services
|
|
| 306 |
var user = await _userRepo.GetByIdAsync(currentUserId);
|
| 307 |
if (user == null) throw new Exception("User not found.");
|
| 308 |
|
| 309 |
-
|
|
|
|
|
|
|
|
|
|
| 310 |
{
|
| 311 |
if (dto.Nodes.Count > 200)
|
| 312 |
{
|
|
@@ -396,11 +402,14 @@ namespace FlowAPI.Application.Services
|
|
| 396 |
var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId);
|
| 397 |
int currentSharedCount = shares?.Count() ?? 0;
|
| 398 |
|
| 399 |
-
|
|
|
|
|
|
|
|
|
|
| 400 |
{
|
| 401 |
throw new InvalidOperationException("Free tier is limited to 2 people on a board (1 guest).");
|
| 402 |
}
|
| 403 |
-
else if (
|
| 404 |
{
|
| 405 |
throw new InvalidOperationException("Pro tier is limited to 10 people on a board (9 guests).");
|
| 406 |
}
|
|
|
|
| 144 |
var user = await _userRepo.GetByIdAsync(currentUserId);
|
| 145 |
if (user == null) throw new Exception("User not found.");
|
| 146 |
|
| 147 |
+
var tier = user.SubscriptionTier?.Trim();
|
| 148 |
+
bool isFree = string.IsNullOrEmpty(tier) || tier == "Free";
|
| 149 |
+
|
| 150 |
+
if (isFree)
|
| 151 |
{
|
| 152 |
var ownedGraphsCount = (await _repo.GetAllByUserIdAsync(currentUserId)).Count();
|
| 153 |
if (ownedGraphsCount >= 3)
|
|
|
|
| 309 |
var user = await _userRepo.GetByIdAsync(currentUserId);
|
| 310 |
if (user == null) throw new Exception("User not found.");
|
| 311 |
|
| 312 |
+
var tier = user.SubscriptionTier?.Trim();
|
| 313 |
+
bool isFree = string.IsNullOrEmpty(tier) || tier == "Free";
|
| 314 |
+
|
| 315 |
+
if (isFree)
|
| 316 |
{
|
| 317 |
if (dto.Nodes.Count > 200)
|
| 318 |
{
|
|
|
|
| 402 |
var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId);
|
| 403 |
int currentSharedCount = shares?.Count() ?? 0;
|
| 404 |
|
| 405 |
+
var ownerTier = owner.SubscriptionTier?.Trim();
|
| 406 |
+
bool ownerIsFree = string.IsNullOrEmpty(ownerTier) || ownerTier == "Free";
|
| 407 |
+
|
| 408 |
+
if (ownerIsFree && currentSharedCount >= 1)
|
| 409 |
{
|
| 410 |
throw new InvalidOperationException("Free tier is limited to 2 people on a board (1 guest).");
|
| 411 |
}
|
| 412 |
+
else if (ownerTier == "Pro" && currentSharedCount >= 9)
|
| 413 |
{
|
| 414 |
throw new InvalidOperationException("Pro tier is limited to 10 people on a board (9 guests).");
|
| 415 |
}
|
FlowAPI.Application/Services/HabitService.cs
CHANGED
|
@@ -32,7 +32,10 @@ namespace FlowAPI.Application.Services
|
|
| 32 |
var existing = await _repo.GetRecordForDateAsync(dto.UserId, dto.HabitName, targetDate.Date);
|
| 33 |
if (existing is not null) return MapToDto(existing);
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
{
|
| 37 |
var allRecords = await _repo.GetAllByUserIdAsync(dto.UserId);
|
| 38 |
var distinctHabits = allRecords.Select(r => r.HabitName).Distinct().ToList();
|
|
|
|
| 32 |
var existing = await _repo.GetRecordForDateAsync(dto.UserId, dto.HabitName, targetDate.Date);
|
| 33 |
if (existing is not null) return MapToDto(existing);
|
| 34 |
|
| 35 |
+
var tier = user.SubscriptionTier?.Trim();
|
| 36 |
+
bool isFree = string.IsNullOrEmpty(tier) || tier == "Free";
|
| 37 |
+
|
| 38 |
+
if (isFree)
|
| 39 |
{
|
| 40 |
var allRecords = await _repo.GetAllByUserIdAsync(dto.UserId);
|
| 41 |
var distinctHabits = allRecords.Select(r => r.HabitName).Distinct().ToList();
|