Using C#: I\'ve created an MVC project in MS Visual Studios. I\'ve added the dat
ID: 3591725 • Letter: U
Question
Using C#:
I've created an MVC project in MS Visual Studios.
I've added the database with the following tables with respective properties:
- Entries ((ID) Next, Prev, Name, Phone, Email)
- Fronts ((ID) FrontID)
- Rears ((ID) RearID)
- Sizes ((ID) TheSize)
I need help writing the code that would use database manipulation method pop() and push() to add NewEntry (push) or delete Entry (pop),
each method should also obtain the count when complete of entries. Not using stack methods, code must be the database methods. See below //
For my HTTPPOST code I have:
[HttpPost]
public ActionResult Index(string button, FormCollection form)
{
ViewBag.Message = "Welcome to the Stack of Names Database:";
ViewBag.theName = "";
ViewBag.thePhone = "";
ViewBag.theEmail = "";
if (button == "Push" && form["Name"] != "")
{
// Need code here
}
else if (button == "Pop" && GetSize() > 0)
{
// Need code here
}
ViewBag.Count = GetSize();
return View(GetDBList());
}
--------------------------------------------
For the action methods I have:
public void Push(Entry newEntry)
{
// Need code here
}
public Entry Pop()
{
// Need code here
}
Thank yo.
Explanation / Answer
public ActionResult Index(string button, FormCollection form)
{
ViewBag.Message = "Welcome to the Stack of Names Database:";
ViewBag.theName = "";
ViewBag.thePhone = "";
ViewBag.theEmail = "";
if (button == "Push" && form["Name"] != "")
{
// Need code here
}
else if (button == "Pop" && GetSize() > 0)
{
// Need code here
}
ViewBag.Count = GetSize();
return View(GetDBList());
}
--------------------------------------------
For the action methods I have:
public void Push(Entry newEntry)
{
// Need code here
}
public Entry Pop()
{
// Need code here
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.