Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

Need Help in MVC web Api

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
Vikash p
Asked:
Vikash p
  • 2
  • 2
1 Solution
 
käµfm³d 👽Commented:
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
 
Vikash pAuthor Commented:
Can you just solve the problem .. and return View(patient_care.ToList());
0
 
käµfm³d 👽Commented:
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
 
Vikash pAuthor Commented:
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
 
apeterCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now