This is a code fragment from my controller
[HttpPost]
public ActionResult Cancel(string id,FormCollection collection)
{
//This is how I would like to declare appt but I cannot seem to correctly pass id into this method
//var appt = Application.Session.GetObjectFromOid<Appointment>(new ObjectId(id));
//I am trying to do it this way instead but I get an error
var appt = (Appointment)Application.Appointments.Where(a=>a.Id.Equals(collection["Id"]));
.....
}
This is the error that I get:Unable to cast object of type ‘WhereListIterator`1[Web.Model.Appointment]’ to type ‘Web.Model.Appointment’.
This is my view:
<input type="button" value="Save" onclick="updateCancel(); return false;" /><button>Save</button>
and this is my function
function updateCancel() {
$('#cancel').ajaxSubmit({
});
}
So why am I getting this error?
OR is there a way to pass Model.Data.Id into my function so that I can just use id instead?
This is what I ended up using and it worked.