I am trying to learn and build an web application using asp.net MVC 5, WEB API 2 and AngularJS. I have already built up a good working application with custom CRUD operations. Now I want complete control on the web api controller, so that I can return data as per my requirement. For example I want to get the returned data from the following code -
string today = DateTime.Now.ToString("dd/MM/yyyy");
var appointment1 = from prescription in db.Prescriptions
where prescription.appointment == "15/01/2015"
from consultation in prescription.Consultations
select new
{
ID = prescription.id,
Name = prescription.patient_name,
Contact = prescription.patient_contact,
Task = prescription.next_task
};
var appointment2 = from consultation in db.Consultations
where consultation.next_date == "15/01/2015"
select new
{
ID = consultation.Prescription.id,
Name = consultation.Prescription.patient_name,
Contact = consultation.Prescription.patient_contact,
Task = consultation.next_task
};
var finalAppointments = appointment1.Concat(appointment2);
return finalAppointments;
I have three questions: 1) Is there any way to retrieve the returned data other than creating custom methods in my web api controller? 2) Can I just use the default method by modifying it a bit? if so then how? 3) If I SHOULD use a custom method what would be the method structure with returned data type?