Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to develop a notification feature and would like to use messages templates for the notifications.

I do have a table which stores those events and who are the subjects and objects of the message.

However, I am lacking a means to show the message templates to the users.

I know I can store the final messages as TEXT in the database but I was wondering if there is a way to store the template some how and merge that template with the data to make it easier for future updates as and when there are new templates or template changes.

What I have tried:

I am currently using the ASP.NET MVC model for the notifications page so only the properties are seen for now.

Index.cshtml
HTML
...
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Id)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DateTime)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Types)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Subject)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Object)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Status)
        </td>
        <td>
            @Html.ActionLink("Details", "Details", new { id = item.Id })
        </td>
    </tr>
}
...


NotificationController.cs
C#
public async Task<ActionResult> Index()
{
    String UserId = HttpContext.User.Identity.GetUserId(); 
    var notifications = db.notifications.Where(n => n.UserId == UserId);
    return View(await notifications.ToListAsync());
}
Posted
Comments
Laxmidhar tatwa technologies 1-Dec-19 1:43am    
you can stored in cookies

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900