Solved

Need Help in MVC web Api

Posted on 2014-04-23
6
412 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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
Can you just solve the problem .. and return View(patient_care.ToList());
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now