How to call function Next on View Create where click Next Button? [on hold]












-2














Problem



How to get next id when click on button next ?



meaning if i have textbox employee id 2 then click next
it must show 3 .



Actually what must i write under BtnNext on view to call Next Function



public class EmployeesController : Controller
{
private readonly IEmployees _context;

public EmployeesController(IEmployees context)
{
_context = context;
}





// GET: Employees/Create
public IActionResult Create()
{
var model = new Employee();
model.EmployeeId = _context.GetAll().Max(Employee => Employee.EmployeeId) + 1;




return View(model);

}
public ActionResult Next(int id)
{
var nextID = _context.GetAll().OrderBy(i => i.EmployeeId)
.SkipWhile(i => i.EmployeeId != id)
.Skip(1)
.Select(i => i.EmployeeId);


ViewBag.NextID = nextID;

return View("Create");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Employee employee)
{
if (ModelState.IsValid)
{

if (employee.EmployeeId <= 0)
{
await _context.InsertAsync(employee);
}

else
{
await _context.UpdateAsync(employee);
}

return RedirectToAction("Index");
}

return View(employee);

}


}
}
view create in employee controller
<div class="row">

<div class="col-md-4">

<button id="BtnNext" style="display:inline"><b>Next</b></button>

<form asp-action="Create">

<div asp-validation-summary="ModelOnly" class="text-danger">

</div>

<div class="form-group">

<label asp-for="EmployeeId" class="control-label"></label>

<input asp-for="EmployeeId" class="form-control" />

<span asp-validation-for="EmployeeId" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="BranchCode" class="control-label">
</label>

<input asp-for="BranchCode" class="form-control" />

<span asp-validation-for="BranchCode" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="EmployeeName" class="control-label"></label>

<input asp-for="EmployeeName" class="form-control" />

<span asp-validation-for="EmployeeName" class="text-danger"></span>

</div>


<div class="form-group">

<input type="submit" value="Create" class="btn btn-default" />
</div>

</form>

</div>

</div>



public class Employee
{
[Key]
public int EmployeeId { get; set; }
public int BranchCode { get; set; }
public string EmployeeName { get; set; }
}









share|improve this question







New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Paul, 200_success, Heslacher, Raystafarian, Pieter Witvoet 18 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, Raystafarian, Pieter Witvoet

If this question can be reworded to fit the rules in the help center, please edit the question.













  • I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
    – bruglesco
    yesterday
















-2














Problem



How to get next id when click on button next ?



meaning if i have textbox employee id 2 then click next
it must show 3 .



Actually what must i write under BtnNext on view to call Next Function



public class EmployeesController : Controller
{
private readonly IEmployees _context;

public EmployeesController(IEmployees context)
{
_context = context;
}





// GET: Employees/Create
public IActionResult Create()
{
var model = new Employee();
model.EmployeeId = _context.GetAll().Max(Employee => Employee.EmployeeId) + 1;




return View(model);

}
public ActionResult Next(int id)
{
var nextID = _context.GetAll().OrderBy(i => i.EmployeeId)
.SkipWhile(i => i.EmployeeId != id)
.Skip(1)
.Select(i => i.EmployeeId);


ViewBag.NextID = nextID;

return View("Create");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Employee employee)
{
if (ModelState.IsValid)
{

if (employee.EmployeeId <= 0)
{
await _context.InsertAsync(employee);
}

else
{
await _context.UpdateAsync(employee);
}

return RedirectToAction("Index");
}

return View(employee);

}


}
}
view create in employee controller
<div class="row">

<div class="col-md-4">

<button id="BtnNext" style="display:inline"><b>Next</b></button>

<form asp-action="Create">

<div asp-validation-summary="ModelOnly" class="text-danger">

</div>

<div class="form-group">

<label asp-for="EmployeeId" class="control-label"></label>

<input asp-for="EmployeeId" class="form-control" />

<span asp-validation-for="EmployeeId" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="BranchCode" class="control-label">
</label>

<input asp-for="BranchCode" class="form-control" />

<span asp-validation-for="BranchCode" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="EmployeeName" class="control-label"></label>

<input asp-for="EmployeeName" class="form-control" />

<span asp-validation-for="EmployeeName" class="text-danger"></span>

</div>


<div class="form-group">

<input type="submit" value="Create" class="btn btn-default" />
</div>

</form>

</div>

</div>



public class Employee
{
[Key]
public int EmployeeId { get; set; }
public int BranchCode { get; set; }
public string EmployeeName { get; set; }
}









share|improve this question







New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Paul, 200_success, Heslacher, Raystafarian, Pieter Witvoet 18 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, Raystafarian, Pieter Witvoet

If this question can be reworded to fit the rules in the help center, please edit the question.













  • I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
    – bruglesco
    yesterday














-2












-2








-2







Problem



How to get next id when click on button next ?



meaning if i have textbox employee id 2 then click next
it must show 3 .



Actually what must i write under BtnNext on view to call Next Function



public class EmployeesController : Controller
{
private readonly IEmployees _context;

public EmployeesController(IEmployees context)
{
_context = context;
}





// GET: Employees/Create
public IActionResult Create()
{
var model = new Employee();
model.EmployeeId = _context.GetAll().Max(Employee => Employee.EmployeeId) + 1;




return View(model);

}
public ActionResult Next(int id)
{
var nextID = _context.GetAll().OrderBy(i => i.EmployeeId)
.SkipWhile(i => i.EmployeeId != id)
.Skip(1)
.Select(i => i.EmployeeId);


ViewBag.NextID = nextID;

return View("Create");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Employee employee)
{
if (ModelState.IsValid)
{

if (employee.EmployeeId <= 0)
{
await _context.InsertAsync(employee);
}

else
{
await _context.UpdateAsync(employee);
}

return RedirectToAction("Index");
}

return View(employee);

}


}
}
view create in employee controller
<div class="row">

<div class="col-md-4">

<button id="BtnNext" style="display:inline"><b>Next</b></button>

<form asp-action="Create">

<div asp-validation-summary="ModelOnly" class="text-danger">

</div>

<div class="form-group">

<label asp-for="EmployeeId" class="control-label"></label>

<input asp-for="EmployeeId" class="form-control" />

<span asp-validation-for="EmployeeId" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="BranchCode" class="control-label">
</label>

<input asp-for="BranchCode" class="form-control" />

<span asp-validation-for="BranchCode" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="EmployeeName" class="control-label"></label>

<input asp-for="EmployeeName" class="form-control" />

<span asp-validation-for="EmployeeName" class="text-danger"></span>

</div>


<div class="form-group">

<input type="submit" value="Create" class="btn btn-default" />
</div>

</form>

</div>

</div>



public class Employee
{
[Key]
public int EmployeeId { get; set; }
public int BranchCode { get; set; }
public string EmployeeName { get; set; }
}









share|improve this question







New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Problem



How to get next id when click on button next ?



meaning if i have textbox employee id 2 then click next
it must show 3 .



Actually what must i write under BtnNext on view to call Next Function



public class EmployeesController : Controller
{
private readonly IEmployees _context;

public EmployeesController(IEmployees context)
{
_context = context;
}





// GET: Employees/Create
public IActionResult Create()
{
var model = new Employee();
model.EmployeeId = _context.GetAll().Max(Employee => Employee.EmployeeId) + 1;




return View(model);

}
public ActionResult Next(int id)
{
var nextID = _context.GetAll().OrderBy(i => i.EmployeeId)
.SkipWhile(i => i.EmployeeId != id)
.Skip(1)
.Select(i => i.EmployeeId);


ViewBag.NextID = nextID;

return View("Create");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Employee employee)
{
if (ModelState.IsValid)
{

if (employee.EmployeeId <= 0)
{
await _context.InsertAsync(employee);
}

else
{
await _context.UpdateAsync(employee);
}

return RedirectToAction("Index");
}

return View(employee);

}


}
}
view create in employee controller
<div class="row">

<div class="col-md-4">

<button id="BtnNext" style="display:inline"><b>Next</b></button>

<form asp-action="Create">

<div asp-validation-summary="ModelOnly" class="text-danger">

</div>

<div class="form-group">

<label asp-for="EmployeeId" class="control-label"></label>

<input asp-for="EmployeeId" class="form-control" />

<span asp-validation-for="EmployeeId" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="BranchCode" class="control-label">
</label>

<input asp-for="BranchCode" class="form-control" />

<span asp-validation-for="BranchCode" class="text-danger"></span>

</div>

<div class="form-group">

<label asp-for="EmployeeName" class="control-label"></label>

<input asp-for="EmployeeName" class="form-control" />

<span asp-validation-for="EmployeeName" class="text-danger"></span>

</div>


<div class="form-group">

<input type="submit" value="Create" class="btn btn-default" />
</div>

</form>

</div>

</div>



public class Employee
{
[Key]
public int EmployeeId { get; set; }
public int BranchCode { get; set; }
public string EmployeeName { get; set; }
}






mvc asp.net-core entity-framework-core






share|improve this question







New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









ahmed abedelazizahmed abedelaziz

1




1




New contributor




ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ahmed abedelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Paul, 200_success, Heslacher, Raystafarian, Pieter Witvoet 18 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, Raystafarian, Pieter Witvoet

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Paul, 200_success, Heslacher, Raystafarian, Pieter Witvoet 18 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Heslacher, Raystafarian, Pieter Witvoet

If this question can be reworded to fit the rules in the help center, please edit the question.












  • I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
    – bruglesco
    yesterday


















  • I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
    – bruglesco
    yesterday
















I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
– bruglesco
yesterday




I'm sorry, [cr] is for improving working code, not to help you implement new features. This simply isn't the place to ask. Once you do have it working bring it back and we can tell you ways to improve it.
– bruglesco
yesterday










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀