Need Help in MVC web Api

Posted on 2014-04-23
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.
Question by:Vikash p
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
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.

Author Comment

by:Vikash p
ID: 40018770
Can you just solve the problem .. and return View(patient_care.ToList());
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?

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.
LVL 25

Accepted Solution

apeter earned 500 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 .

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 54
Import a excel sheet in a grid 2 45
C# Change the instruction to user. 11 39
Example code 13 42
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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