Skip to content

Commit 907455a

Browse files
committed
CU-868bwktan fix pricing page issue, fixed a couple postgres bugs
1 parent abbe651 commit 907455a

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void AddUserToRole(string userId, string roleId)
143143
{
144144
using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString))
145145
{
146-
db.Execute($"INSERT INTO public.aspnetuserroles ([userid] ,[roleid]) VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId });
146+
db.Execute($"INSERT INTO public.aspnetuserroles (\"userid\" ,\"roleid\") VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId });
147147
}
148148
}
149149
else
@@ -161,8 +161,8 @@ public void InitUserExtInfo(string userId)
161161
{
162162
using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString))
163163
{
164-
db.Execute($"INSERT INTO public.aspnetusersext ([userid] ,[createdate] ,[lastactivitydate]) VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow });
165-
db.Execute($"UPDATE public.aspnetusers SET emailconfirmed = 1 WHERE id = @userId", new { userId = userId });
164+
db.Execute($"INSERT INTO public.aspnetusersext (\"userid\" ,\"createdate\" ,\"lastactivitydate\") VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow });
165+
db.Execute($"UPDATE public.aspnetusers SET emailconfirmed = true WHERE id = @userId", new { userId = userId });
166166
}
167167
}
168168
else

Repositories/Resgrid.Repositories.DataRepository/Queries/Common/InsertQuery.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ public string GetQuery<TEntity>(TEntity entity)
2323
if (((IEntity)entity).IdType == 0)
2424
{
2525
ignoredProperties.Add(((IEntity)entity).IdName);
26-
returnId = _sqlConfiguration.InsertGetReturnIdCommand;
26+
27+
if (Config.DataConfig.DatabaseType == Config.DatabaseTypes.Postgres)
28+
{
29+
returnId = $" RETURNING {((IEntity)entity).IdName.ToLower()}";
30+
}
31+
else
32+
returnId = _sqlConfiguration.InsertGetReturnIdCommand;
2733
}
2834

2935
var columns = entity.GetColumns(_sqlConfiguration, ignoreProperties: ignoredProperties);

Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConfiguration.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public PostgreSqlConfiguration()
2424
SchemaName = "public";
2525
TableColumnStartNotation = "\"";
2626
TableColumnEndNotation = "\"";
27-
InsertGetReturnIdCommand =
28-
"; SELECT lastval();"; // For Postgresql INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John') RETURNING id; https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id/2944481
27+
//InsertGetReturnIdCommand =
28+
// "; SELECT lastval();"; // For Postgresql INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John') RETURNING id; https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id/2944481
29+
InsertGetReturnIdCommand = "";
2930
QueryPrefix = DataConfig.QueryPrefix;
3031
#region Common Queries
3132

@@ -391,7 +392,7 @@ SELECT COUNT(*) FROM %SCHEMA%.%MESSAGESTABLE% m
391392
UpdateRoleQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE Id = %ID%";
392393
SelectRoleByNameQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE Name = %NAME%";
393394
SelectRoleByIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE Id = %ID%";
394-
InsertUserQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% OUTPUT INSERTED.Id VALUES(%VALUES%)";
395+
InsertUserQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%) RETURNING id;";
395396
DeleteUserQuery = "DELETE FROM %SCHEMA%.%TABLENAME% WHERE Id = %ID%";
396397
UpdateUserQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE Id = %ID%";
397398
SelectUserByUserNameQuery =

Web/Resgrid.WebCore/Areas/User/Views/Subscription/Index.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@
483483
const amount = slider == 1 ? val : $("#amount").val();
484484
485485
if (amount && amount > 10) {
486-
const packs = amount / 10;
486+
const packs = (amount / 10) - 1; // First 10 users are free.
487487
488488
$.ajax({
489489
url: resgrid.absoluteBaseUrl + '/User/Subscription/GetStripeSession?id=' + id + '&count=' + packs,
@@ -652,7 +652,7 @@
652652
];
653653
654654
let finalCost = 0.0;
655-
let remainingUsers = totalNumUsers / 10;
655+
let remainingUsers = (totalNumUsers / 10) - 1; // First 10 users are free.
656656
let pricingTiers = isMonthly ? pricingTiersMonthly : pricingTiersYearly;
657657
658658
for (let i = 0; i < pricingTiers.length; i++) {

0 commit comments

Comments
 (0)