XD
❔ Why isn't one of my Identity user field being updated?
Code: https://gist.github.com/JsPeanut/b59cc1d4da3ababc532fe3b6e8a9ad69
The void
ChangeUserCategoryValue
, which is called at line 180 and 208, is responsible for changing user's corresponding field. It doesn't work for some reason and I can't figure it out6 replies
❔ Form with put or delete method
Since I can't add a method="put" or "delete" to my forms, how else can I add a put or delete method to my forms? I want to execute a function from the controller after submitting the form that will update/delete. I'm not using actions because this is an SPA, and I can't do something like, specifying a post method in the form and then, in the .cshtmlcs write code for a PUT inside an OnPost function because it's an MVC app
11 replies
❔ Is there a way to make this more cleaner?
As you can see, if is not null, I will add a span that will contain that message. I need two <br> tags in case I show the message. One above my span, and the other one above my <table> tag.
Problem is, I feel those if statements I added don't look very clean. What do you think?
48 replies
❔ I get Invalid ModelType because my hidden field is empty
So I have a field (Unit of measurement) that will be hidden if the user chooses the option ''Check-in''. If the user chooses that option and then uploads the form, the field will be shown, followed by the error ''The UnitOfMeasurement field is required". How can I prevent this from happening?
I want the UnitOfMeasurement field to be equal to "Done"
The cshtml.cs code:
https://pastebin.com/vRYqHbCr
The cshtml code:
https://pastebin.com/QhW9CvRH
2 replies
❔ How do I hide or show a div based on the value of a property of my selected option?
When I select a habit type, that habit type has a Measurability property, and I want to show or hide divs based on the value of this property. How can I do it?
By the way, the reason for which I don't want to do it with the name/value of the selected option, is because I would have to hardcode these options in a JavaScript function, but the user is able to add new habit types.
10 replies
❔ How can I sort my list by day? Razor Pages
The user is able to log and track habits, and I want they to be able to sort their habits in a way like this: - Today - Yesterday - Search for specific date
So I had this idea:
First add this button:
Then, for the post method (just added the code for sorting habits added today to test first):
The problem comes when I press the button. I get an ArgumentNullException right at the line where my ImagePath variable is declared (I guess it is because I removed one of the records from HabitLogs):
https://pastebin.com/3c6kN1E8
Any advice on how can I sort this list? I'm a beginner in Razor Pages
2 replies
❔ Why isn't my form being submitted?
As far as I can see, my form is not being submitted because the HabitType is null (there must be something wrong with the section and option tags but I can't tell)
Basically, the user is supposed to log their habits through a form which will insert the values into the database.
Select and option tags will make the user choose which kind of habit he will log (the HabitLog class contains a HabitType property), the foreach loop will loop through each habit type which exists. The other two ones are for the user to log the date and quantity. Appreciate any help!
LogHabit.cshtml:
https://pastebin.com/CFusfz41
LogHabit.cshtmlcs:
https://pastebin.com/JED3jAMP
HabitLog class:
https://pastebin.com/CJ1HK88K
HabitType class:
https://pastebin.com/Ly8Qtg0i
31 replies
❔ Any tips on how to make this function cleaner? I feel it's a mess
I tried to copy this interactive menu from this video:
https://www.youtube.com/watch?v=YyD1MRJY0qI
Source code: https://github.com/ricardogerbaudo/Console.InteractiveMenu
My code: https://github.com/JsPeanut/InteractiveMenu/blob/main/TestingArea/TestingArea/Program.cs
I feel my function is a mess... Would appreciate any help
32 replies
❔ I tried to substract two TimeSpan objects but nothing happened
I have been trying to add to add a goal feature in my application (a coding tracker), but I haven't been able to update the progress of the goal of the user
What I'm trying to do here is: 1. Store in a variable each coding session which has been started after the first goal was added by the user (example, user added his goal 1 hour ago, so then every coding session after the user added his goal, will be stored)
2. Add to GoalProgress all the durations of those sessions
3. Return GoalProgress to use it later
Then here comes the problem:
I tried to calculate the progress by substracting GoalProgress to GoalValue, but the value of that operation will always be equal to GoalValue (the original goal the user inserted)
This is the void in which the values of my Goal model are inserted into my SQLite database:
14 replies