Closed Korayem closed 13 years ago
Just assign your model to this.ViewData and your view will find it as any other view data passed into it.
Sent from my iPhone
S M Sohan Consultant ThoughtWorks Canada Suite 1100, 600 6th Ave SW Calgary, AB T2P 0S5 Cell: +1 403 714 2673
On 2011-06-24, at 5:21 PM, Korayem reply@reply.github.com wrote:
You may not consider this an "issue" but seeing how MvcMailer is all about MVC, i think not having a model in the view is an "issue". Relying on Viewbag is cool, but why not really follow the MVC pattern?
Would love to have my razor views setup a model type so that I can pass the model into the view using PopulateBody();
This should be possible:
var model = new ModelView(); model.FirstName = "Hello"; model.LastName = "World"; PopulateBody(mailMessage, "RazorView", model);
so that in RazorView.cshtml
@model MyModelView This is a @Model.FirstName @Model.LastName app!
Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/19
Doh!!!
So it should be as simple as
var model = new ModelView(); ViewData = new ViewDataDictionary(model);
Never knew that. Thought I had to pass it as a parameter! I suggest you add this small tip to your wiki post for the ignorant folks like me :)
Sorry for the trouble and a million thanks for the quick response
:)
Sent from my iPhone
S M Sohan Consultant ThoughtWorks Canada Suite 1100, 600 6th Ave SW Calgary, AB T2P 0S5 Cell: +1 403 714 2673
On 2011-06-24, at 11:11 PM, Korayem reply@reply.github.com wrote:
Doh!!!
So it should be as simple as
var model = new ModelView(); ViewData = new ViewDataDictionary(model);
Never knew that. Thought I had to pass it as a parameter! I suggest you add this small tip to your wiki post for the ignorant folks like me :)
Sorry for the trouble and a million thanks for the quick reponse
Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/19#issuecomment-1437020
;) :+1:
You may not consider this an "issue" but seeing how MvcMailer is all about MVC, i think not having a model in the view is an "issue". Relying on Viewbag is cool, but why not really follow the MVC pattern?
Would love to have my razor views setup a model type so that I can pass the model into the view using PopulateBody();
This should be possible:
var model = new ModelView(); model.FirstName = "Hello"; model.LastName = "World"; PopulateBody(mailMessage, "RazorView", model);
so that in RazorView.cshtml
@model MyModelView This is a @Model.FirstName @Model.LastName app!