I’m pretty new in setting up mvc, please be patient..
So I have these two models
public class Promoter
{
public int Id {get; set;}
public string Name {get;set;}
public ICollection<Event> AllEvents {get;set;}
}
public class Event
{
public int Id {get;set;}
public string Name {get;set;}
public date Date {get;set;}
public int PromoterId {get; set;}
public virtual Promoter Promoter {get;set;}
}
And I have a controller Events
public class EventsController : Controller
{
public ActionResult New()
{
return View()
}
[HttpPost]
public ActionResult New(Model model)
{
// do stuff to save the new Event related to Promotion
}
}
so my problem is that, on the New Action, how do I make sure that the New View will be able to have an identifier on which Promoter it will be related to? I’m thinking hiddenfor that has the PromotionId so that when the Post gets called the Id will be there, but I will have to pass the Promoter Id when I call the New action?
Or do you think I should store the Promoter details in a cookie before going to that page?
Another thing to take note, the user will be authenticated and will need to be logged in to be able to access the Promotion controller (not shown in this thread) and then on that controller user can go to the said Event Controller which will have the New Action…
I hope that makes sense.
Need some advice, thoughts / ideas is very much appreciated.
THanks,
G
You’re thinking right, you need to pass promotionId to the new action and action needs to pass it to the view. It is also possible through cookie, but I think action parameter is more convenient – because action parameter will be in url, so user can even bookmark it, send to another user, etc.