I was given a task to prepare for a technical exam and this is the Requirement. I am confused and just wanted to get some thoughts if if the code below met this requirement.
a.)"create web application 2 user role login
b.)create web application with 1 dashboard 2 forms entry (form a & form b, form b is subform of form a)
c.)allow user enter entry in form a, make a boolean in form a. if Boolean = true activate form b for user input, else user can submit form a only. Dashboard display list of form a."
Here's what I have came up:
@page
@model IndexModel
@using Microsoft.AspNetCore.Identity;
@inject SignInManager<IdentityUser> SignInManager
<div id="formA">
<div >
<div >
<h1 >Form A</h1>
<form method="post">
@if (SignInManager.IsSignedIn(User) && User.IsInRole("Admin"))
{
bool bolAdmin = true;
<div >
<label > First Name</label>
<input type="text" />
</div>
if (bolAdmin == true)
{
<div >
<label > Gender</label>
<input type="text" />
</div>
<div >
<button type="submit" >Activate</button>
</div>
}
else
{
<div >
<button type="submit" >Save</button>
</div>
}
}
</form>
</div>
</div>
</div>
CodePudding user response:
In your form1 View include a checkbox like
<input type="checkbox" value="1" name="Proceed"> Proceed Form B
In the Controller for Form A
public ActionResult FormA(yourModel Model, string Proceed)
{
// your save procedure
if (Proceed == "1")
{
Return RedirectToAction("FormB",new{Id = Model.Id});
}
else
{
Return RedirectToAction("Index");
}
}
public ActionResult FormB(int Id)
{
//You may pass the form A Id here to Form B reference
};