Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ASP.NET True and False value does not change

I have a code like this:

public IActionResult Urgent(TodoTable t)
{
    var Task = db.TodoTables.SingleOrDefault(i => i.Id == t.Id);
    Task!.Urgent = t.Urgent; // If the value is True it will change to False and if False it will change to True.
    db.SaveChanges();
    return RedirectToAction("Index");
}

And Index.cshtml:

<a class="dropdown-item" href="/TodoTables/Urgent/@item.Id">@(item.Urgent ? "Unurgent" : "Urgent")</a>

If the Urgent value in the database is True, it will be False, and if False, it will be True. But I could not do this on the Controller side. Only True becomes False, then does not become True again.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I do that? Thanks for the help.

>Solution :

Can you try replacing your code like this?

Task.Urgent = !Task.Urgent;

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading