This might be difficult to explain but please bear with me... So, I have a model that combines two different models so that I can utilize data found in both in one view: Combined:
public class EventFullModel
{
public AccessListModel AccessPointsList;
public EventListModel EventList;
}
Access List Model:
public class AccessListModel
{
public int Id { get; set; }
public List<SelectListItem> AccessPoints { get; set; }
}
Event List Model:
public class EventListModel
{
public int Id { get; set; }
public virtual string T { get; set; }
public virtual string C { get; set; }
public virtual string M { get; set; }
public virtual string L { get; set; }
public List<SelectListItem> Events { get; set; }
public IEnumerable<SelectListItem> Skills { get; set; }
}
I am currently getting an error which I believe stems from the fact that the controller method for this view originally returned just the EventListModel whereas now it is trying to return the EventFullModel since I changed the inheritance: Inherits="System.Web.Mvc.ViewPage<cred.web.models.eventfullmodel>". So at this point I am trying to edit the controller to make sure it attempts to return the correct model for the view. My problem is the following:
This is a GET action method that only accepts (int? id) as a parameter.
Originally, the controller worked only with the EventListModel:
EventListModel model;
model = new EventListModel {
Id = 0,
T = "",
C = "",
M = "",
L = HttpContext.Session["L"].IsNull() ? "" : HttpContext.Session["L"].ToString(),
Events = new List<SelectListItem>(),
Skills =
DbQueryExecutor.ExecuteQuery(new SkillsList()).Select(e => new SelectListItem { Text = e.Certification, Value = e.Certification, Selected = false })
So I am basically wondering, how can I edit this to access those pieces of the EventListModel but have my model = new EventFullModel?
(Disclaimer: I have altered the names of a few things and I am working to edit a piece of software that I did not originally write so I am trying to change as little as possible in the hopes of not "breaking" other pieces of the software)