The details are being fetched in the controller correctly but value passed in the view is incorrect. Therefore I am getting the following error:
The model item passed into the dictionary is of type 'System.Int64', but this >dictionary requires a model item of type >'estatebranch.ViewModels.RentRegisterViewModel'
My controller has following action method
public ActionResult RentRegister(int propertyId)
{
try
{
using (estatebranchEntities db = new estatebranchEntities())
{
RentRegisterViewModel objRentRegister = new RentRegisterViewModel();
objRentRegister.balance = db.PropertyDetails.Where(m => m.propertyid == propertyId).Select(m => m.balance).SingleOrDefault();
return View(objRentRegister.balance);
}
}
catch (Exception)
{
throw;
}
}
My View model is as follow:
public class RentRegisterViewModel
{
public int recordid { get; set; }
public int propertyid { get; set; }
public int month { get; set; }
public int year { get; set; }
public long amountpaid { get; set; }
public System.DateTime paymentdate { get; set; }
public long interest { get; set; }
public Nullable<long> balance { get; set; }
public virtual PropertyDetail PropertyDetail { get; set; }
}