How to redisplay the current view and conditionally set a variable?

Chris Allen 21 Reputation points
2021-06-10T21:53:30.77+00:00

Hello all, I apologize if this is an extremely simple task but I could not find an example. Working on a very simple scheduling app and want to allow users to either extend their current "booked" availability or change to "Out of Office"
When changing to out of office by check box, I would like to refresh the current view to reflect the "new status" change from checkbox selection.

104442-image.png

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,187 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,276 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points
    2021-06-11T00:09:40.78+00:00

    Look at what is happening with the Payroll on Create or Edit. A HTTPGet is being done, then a HTTP post for the same action method is being done with the ViewModel being posted back to the action method. In your case as the viewmodel is posted back to the action method, you have access to all properties that are populated by the view on the VM object that was passed into the controller from the view, and you can update the VM and return the viewmodel to the view, if that's what you need to do.

    https://github.com/darnold924/PublishingCompany/blob/master/PublishingCompany/Models/PayRollVM.cs

    https://github.com/darnold924/PublishingCompany/blob/master/PublishingCompany/Views/PayRoll/Edit.cshtml

    https://github.com/darnold924/PublishingCompany/blob/master/PublishingCompany/Controllers/PayRollController.cs

    Understand method overloading. It's being used in the examples.

    https://www.geeksforgeeks.org/c-sharp-method-overloading/

    https://p2p.wrox.com/book-professional-asp-net-mvc-1-0-isbn-978-0-470-38461-9/87424-how-pass-model-beginform-use-formmethod-post.html

    Understand the models in MVC...

    https://deviq.com/terms/kinds-of-models

    Understand the viewmodel..
    https://www.dotnettricks.com/learn/mvc/understanding-viewmodel-in-aspnet-mvc

    project out on GitHub..

    https://github.com/darnold924/PublishingCompany