Every time I click on details for an item it gives me the error and the id is equal to 0, but if change the id number to anything greater than 1 within the number of items I have it runs properly Here is my method
public PhoneModel GetPhone(int id)
{
using(var context = new ElectronicsDataBaseEntities())
{
var result = context.Phone
.Where(x => x.Id == id)
.Select(x => new PhoneModel()
{
Name = x.Name,
Phonemodel = x.Model,
DateReleased = x.DateReleased,
Desicription = x.Desicription
})
.FirstOrDefault();
return result;
}
}
and this my action method in the controller
public ActionResult Details(int id)
{
var result = repository.GetPhone(id);
return View(result);
}