-1

I am working on returning a view which was scaffolded off of the AnalyticsViewModel viewmodel. I am trying to create an object of type AnalyticsViewModel to pass as the object model to the BuyerDetails view (Which is located in the campaigns view folder). The issue I'm having is the conversion of type so that I can pass the object to the view. The following code is where I am stuck.

 public ActionResult BuyerDetails(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Campaign buyers = db.Campaigns.Find(id);
        AnalyticsViewModel buyer = buyers;
        if (buyer == null)
        {
            return HttpNotFound();
        }
        return View(buyer);
    }
Carter
  • 3
  • 2

1 Answers1

0

After much google, I found the answer in case anyone else can benefit from this. I am new to the context so it took me a while but it's an easy fix.

I replaced AnalyticsViewModel buyer = buyers;

with AnalyticsViewModel buyer = new AnalyticsViewModel(buyers);

Carter
  • 3
  • 2