I have a DNN applicacation and I managed to put a custom module. The module is basically incrementing and decrementing value in a label. And there also have a button named submit which displays only a positive value in the label which is also the value that are being incremented and decremented. The purpose is just for counting the download of a user in an application.
Now here is my decrement code: public void doDecrement(string propertyKey, UserInfo userInformation, int portalID) { int newDownloadCount = GetProfilePropertyValueAsInt(propertyKey, userInformation); ; int result = 0; result = newDownloadCount - 1; userInformation.Profile.SetProfileProperty(propertyKey, result.ToString()); UserController.UpdateUser(portalID, userInformation); }
And here is my increment code:
public void doIncrement(string propertyKey, UserInfo userInformation, int portalID)
{
int newDownloadCount = GetProfilePropertyValueAsInt(propertyKey, userInformation);
int result = 0; //initialize to zero
result = newDownloadCount + 1; //assign new value
//set the profile property to RAM... no need to test because Get will default to zero
userInformation.Profile.SetProfileProperty(propertyKey, result.ToString());
//call update user to write the changes to disk
UserController.UpdateUser(portalID, userInformation);
}
Here is my submit code so I can update the value:
public void UpdatePropertyValue(string propertyKey, UserInfo userInformation, int portalID, string txtNewVale)
{
int newDownloadCount = 0;
int resultValue = 0;
int.TryParse(txtNewVale, out newDownloadCount);
if (String.IsNullOrEmpty(txtNewVale))
{
newDownloadCount = resultValue;
}
userInformation.Profile.SetProfileProperty(propertyKey, newDownloadCount.ToString());
UserController.UpdateUser(portalID, userInformation);
}
My problem now is,I'm experiencing a road block. I want to save the incremented value in database using postgres. I want that whenever the value is incremented or decremented or updated, it will be save to the database.
I would really appreciate anyone that could help. Thank you in advance.