Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need Help in MVC web Api

Posted on 2014-04-23
6
Medium Priority
?
478 Views
Last Modified: 2014-05-15
Hi ,

I am using MVC 6.0 and new to it . I have generated MVC Controler with EF 5 DBContext generator.

My Index Action is

 public ActionResult Index()
        {
            var patient_care = db.Patient_Care.Include(p => p.Person).Include(p => p.Referal);
           
            return View(patient_care.ToList());
        }

Now I want to pass parameter and return the view

Public ActionResult IndexStatus(string status)
{


}

Status a field in Patient table and it should return the type of patient as per parameter passed to index.
0
Comment
Question by:Vikash p
  • 2
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40018752
What do you mean by, "...and return the view?" Web API generally doesn't deal with views, though it can return HTML as data.
0
 

Author Comment

by:Vikash p
ID: 40018770
Can you just solve the problem .. and return View(patient_care.ToList());
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40018942
I'm afraid I'm confused, and I'm hoping you can clarify how your project is set up. Do you have an MVC project or a Web API project?
0
 

Author Comment

by:Vikash p
ID: 40019026
its a MVC 6 project and i have generated Controlers with EF 5 code builder . i am more a database guy . now they need web api . I need to add something like where clause to
            var patient_care = db.Patient_Care.Include(p => p.Person).Include(p => p.Referal);

we need to pass status as parameter and it should return records with that type of status.
0
 
LVL 25

Accepted Solution

by:
apeter earned 2000 total points
ID: 40029334
Why you need a web api. Create a new action link , which is clicked pass the status to the controller.

Now you can use the same dbcontext, to use the parameter .
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question