0

I have a problem with a view I have been using this fine for others my class is as follows

namespace WebApplication1.Models
{
public class Reviews
{

    public int ReviewId { get; set; }
      public DateTime ReviewDate { get; set; }
             public string ReviewedBy { get; set; }
    public string ShortDescription { get; set; }


    public double Localknowledge { get; set; }

    public double Processexpertise { get; set; }

    public double Responsiveness        { get; set; }
    public double NegotiationSkills  { get; set; }

   }
}

I am using it in my agent class as follows as a list but

 public class Agents
 {

    public int AgentId { get; set; }
    public int RatingsId { get; set; }
    public string Name { get; set; }
    public string About { get; set; }

    public string Bookerish { get; set; }

    public string Specialties { get; set; }

    public int LicenseNo { get; set; }
    public string image { get; set; }

    public double LocalKnowledge { get; set; }

    public double ProcessExpertise { get; set; }

    public double Responsiveness { get; set; }
    public double NegotiationSkills { get; set; }


    public double RatingAverage { get; set; }


    public List<Property> Properties { get; set; }


    public List<PastSales> PastSales { get; set; }

    public List<Reviews> Reviews { get; set; }
 }
}

In my index file I am using the following to load the view same as the others

         <div class="l-divider l-divider--big"></div>
            @Html.Partial("Reviews.cshtml", Model.Reviews)

In My Agent controller i have 


            _newAgent.PastSales = new List<PastSales> {
                new PastSales { PastSalesId=1,address="3247 Greystone Dr • Jamul, CA 91935",image="/images/property/home5.jpg", Beds=7,Baths=4,SQFT="6,150" ,SoldDate= Convert.ToDateTime("12/09/2017"),Represented="Seller",Price=Convert.ToDecimal(900.0000m) },
                 new PastSales { PastSalesId=2,address="9951 Watergum Trl • Santee, CA 92071",image="/images/property/home4.jpg", Beds=6,Baths=5.5,SQFT="5,505" ,SoldDate= Convert.ToDateTime("21/7/2017"),Represented="Buyer",Price=Convert.ToDecimal(490.000m) },
                  new PastSales { PastSalesId=3,address="627 Hawthorne Ave • El Cajon, CA 92020", image="images/property/home12.jpg", Beds=6,Baths=5.5,SQFT="5,505" ,SoldDate= Convert.ToDateTime("11/09/2017"),Represented="Buyer",Price=Convert.ToDecimal(522.000m) },
                    new PastSales { PastSalesId=4,address="9565 Janfred Way • La Mesa, CA 91942", image="images/property/home6.jpg", Beds=6,Baths=5.5,SQFT="5,505" ,SoldDate= Convert.ToDateTime("11/09/2017"),Represented="Buyer",Price=Convert.ToDecimal(555.000m) },
                      new PastSales { PastSalesId=5,address="5160 Alzeda Dr • La Mesa, CA 91941", image="images/property/home7.jpg", Beds=6,Baths=5.5,SQFT="5,505" ,SoldDate= Convert.ToDateTime("11/09/2017"),Represented="Buyer",Price=Convert.ToDecimal(1.265) },

            };

            _newAgent.Reviews = new List<Reviews> { new Reviews { ReviewId=1, ReviewedBy="russroberts"}       };
            return View(_newAgent);
        }

So Please can someone tell me why i am getting the following

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Int32', but this ViewDataDictionary instance requires a model item of type 'System.Collections.Generic.List`1[WebApplication1.Models.Reviews]'.

When my view is like below

@model List<Reviews>

<h3>Ratings &amp; Reviews</h3>
<div class="c-content__filter c-content__filter--reviews h-clearfix">
    <div class="l-col l-col-4 l-col-xs-6">
        <select class="l-form-control l-form-select l-form-elem-custom" id="reviewType_ReviewFilter">
            <option>All reviews (16)</option>
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
        </select>
    </div>
    <div class="l-col l-col-4 l-col-xs-6">
        <select class="l-form-control l-form-select l-form-elem-custom" id="reviewOrder_ReviewFilter">
            <option>Newest first</option>
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
        </select>
    </div>
    <div class="l-col l-col-4 h-hide-on-mobile">
        <button type="button" class="l-btn l-btn--action l-btn--blue">Write a Review</button>
    </div>
</div>

@foreach (var item in Model)
{
<div class="c-content__reviews">

}
c-sharp-and-swiftui-devni
  • 3,743
  • 4
  • 39
  • 100

0 Answers0