Closed ga5tan closed 4 years ago
Mhn, I wouldn't put a whole cshtml into the db. Not only because it's not MVC anymore then. The cshtml content (the actualy file's content), is mostly static for longer periods - you design/develop - go live - until a rework/redesign - you usually dont change a lot. And most of the changes happening then are CSS-based, or is your requirements profile different?
Some ideas:
Store the .cshtml in App_Data (or within some folder on the MVC-Views part of your application) and simply read it (when edit is needed) and display it like you would display it when coming from a DB (the source doesn't define the way you make it accessible) - for direct editing simply read the content into HTML editor like Serenity's and write it back after editing. Or simply let them download the file and reupload it.
Keep the .cshtml not editable, but create relative entries for elements, colors etc. in DB and make your own simple or just let them down/upload/directly edit CSS (more secure, even better seperation according to MVC principles).
How I do the email stuff:
If you want, feel free to message me to discuss it - always eager to see what solutions others find/use .
@RKayCH thx for elaborate post! Yeah, I thought about just storing parts of the template in DB or even better in Serenity scripts, so that I can get the power of multilanguage and translations...
Letting users(Admins) to edit file would also be nice...I just thought editing it in DB would be more "elegant" aproach You are right it wont be happening often, but still would be better than have to release new version because of this...Or reuploading individual files
I see you points, in the end, the elegance comes from the editing options - not the source, as nobody would see anything which is hidden "behind the curtains".
The actual data (text - in regards to the translations you mentioned) - I would keep on the DB. Text (which is DATA) - if strictly following MVC - should not be part of the template cshtml itself, but depending on your project/size, it could be a bit overkill to do it that strict. In th end, it's mostly a question of cost-effectiveness analysis and "internal guidelines" on the team.
Anyway, let me know how it's going and if you have further questions. Cheerio
You may use scriban/markdown for email templates, and could store them in db as well.
Hi
so I am using Serenity's way, to send out email:
`var emailModel = new TransferRegistrationEmailModel(); emailModel.QA = user.DisplayName; emailModel.Code = TransferCode; emailModel.Url = URL;
but I would need to be able for users to modify cshtml template. Did anybody tried that? I would most likely want ot have cshtml is DB table. is it possible to use from table, rather than from field?