When I logged in user visits their profile vial Manage
-> Index.cshtml
, I want to display to them all the orders made through the organisation which they belong to.
These orders are usually displayed in an organisation's Details.cshtml
with
@{Html.RenderAction("Index", "Order", new { org = Model });}
Where model
contains a ViewOrganisationViewModel
, where all the orders are stored.
This works perfectly.
Now when I want to do the same for a logged in user, I tried:
Manage Index.html
@{Html.RenderAction("MyIndex", "Order");}
OrderController.cs
Here I added the MyIndex
method, which first gets the user's OrganisationId
in order to build the correct ViewOrganisationViewModel
. This entire method runs without error.
public ActionResult Index(ViewOrganisationViewModel org)
{
return PartialView(org.Orders);
}
public ActionResult MyIndex()
{
Models.ApplicationUser user =
System.Web.HttpContext.Current.GetOwinContext()
.GetUserManager<ApplicationUserManager>()
.FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
var organisationManager = new OrganisationManager();
var org = organisationManager.Select(user.OrganisationId);
return View("Index", org);
}
Now when the applications tries to return to Index(ViewOrganisationViewMode org)
, I get:
The model item passed into the dictionary is of type 'AuroraWeb.ViewOrganisationViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[AuroraWeb.ViewOrderViewModel]'.
Why is it doing this? The method does not expect an IEnumerable
of the ViewModel, so am I missing something here?
I also tried changing the return
line in MyIndex
to
return Index(org);
But it then complains that there is no MyIndex.cshtml
view (Which there isn't because I only need to return the Index
view..)
I also tried
return RedirectToAction("Index", new { org = org });
but got
Child actions are not allowed to perform redirect actions.
Please let me know if I can provide any extra details.