Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Forums application using MVC4 and Entity Framework

, 15 Feb 2013
I would like to share the application which is done in MVC4 using Entity Framework.
mvcForumapp-noexe.zip
mvcForumapp
App_Start
bin
Content
css
themes
base
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
minified
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
Global.asax
Models
mvcForumapp.csproj.user
mvcforums.edmx
obj
Debug
edmxResourcesToEmbed
mvcforums.csdl
mvcforums.msl
mvcforums.ssdl
Properties
Scripts
Views
Login
Logout
Question
Question_Answer
Register
Reply
Shared
Technology
mvcForumapp.zip
App_Data
Antlr3.Runtime.dll
EntityFramework.dll
Microsoft.Web.Infrastructure.dll
mvcForumapp.dll
mvcForumapp.pdb
Newtonsoft.Json.dll
System.Net.Http.dll
System.Net.Http.Formatting.dll
System.Net.Http.WebRequest.dll
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Web.Mvc.dll
System.Web.Optimization.dll
System.Web.Providers.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll
WebGrease.dll
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Global.asax
mvcForumapp.csproj.user
mvcforums.edmx
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
mvcforums.csdl
mvcforums.msl
mvcforums.ssdl
mvcForumapp.dll
mvcForumapp.pdb
ResolveAssemblyReference.cache
TempPE
mvcforums.Designer.cs.dll
video2.zip
video2.avi
@model IEnumerable<mvcForumapp.Questionwithreplys_Result>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style type="text/css">
    .disabled
    {
        /* Text and background colour, medium red on light yellow */
        float: right;
        margin-right: 20px;
        background: #999;
        background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#dadada), to(#f3f3f3));
        border-top: 1px solid #c5c5c5;
        border-right: 1px solid #cecece;
        border-bottom: 1px solid #d9d9d9;
        border-left: 1px solid #cecece;
        color: #8f8f8f;
        box-shadow: none;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        cursor: not-allowed;
        text-shadow: 0 -1px 1px #ebebeb;
    }
    .active
    {
        box-shadow: none;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        cursor: allowed;
    }
</style>
<br />
<div style="float: left; margin-left: 20px;">
    @foreach (var item in Model)
    {
        @Html.ActionLink("Back", "DisplayQuestions", "Technology", new { TechID = item.TechID }, null)
        break;
    }
</div>
<div class="topic_controls">
    <br />
    <ul class="comRigt" runat="server" id="lnkTopic">
        <li>
            <img alt="Add Reply" src="http://www.gimptalk.com/public/style_images/master/arrow_rotate_clockwise.png" />
            @if (Session["UserName"] != null)
            {

                foreach (var item in Model)
                {   
                @Html.ActionLink("Add Reply", "PostReply", "Reply", new { @class = "active", onclick = "javascript:return true;", QuestionID = item.QuestionID, TechID = item.TechID }, null)
                    break;
                }
            }
            else
            {
                foreach (var item in Model)
                {
                @Html.ActionLink("Add Reply", "PostReply", "Reply", new { title = "Please login to post replys", TechID = item.QuestionID, @class = "disabled", onclick = "javascript:return false;" })
                    break;
                }
            }
        </li>
    </ul>
    <br />
    <h2 class="maintitle">
        <span class="main_topic_title">
            @foreach (var item in Model)
            {
                string strTopic = item.QuestionTitle;
                @Html.Label("Topic", strTopic)
                break;
            }
        </span>
    </h2>
    <br />
    <div class="post_wrap">
        <h3>
            &nbsp; <span class="author vcard">
                @foreach (var item in Model)
                {
                    string User = item.quesaskedby;
                    @Html.ActionLink(User, "Details", "Home", new { Username = item.quesaskedby }, null)
                    break;
                }
                @*<asp:linkbutton id="lnkUsername" runat="server" text='<%#Eval("UserName") %>' font-underline="false"></asp:linkbutton>*@
            </span>
        </h3>
        <div class="authornew">
            <ul>
                <li class="avatar">
                    @foreach (var item in Model)
                    {
                        <img alt="" src="@Url.Action("GetPhoto", "Question_Answer", new { QuestionID = item.QuestionID })" height="100" width="100" class="photo" />
                        break;
                    }
                </li>
            </ul>
        </div>
        <div class="postbody">
            <p class="postnew">
                @foreach (var item in Model)
                {
                    DateTime dt = Convert.ToDateTime(item.DatePosted);
                    string strDate = dt.ToString("dd MMMM yyyy - hh:mm tt");
                    @Html.Label(strDate)
                    break;
                }
                @*<asp:label id="lblDateposted" text='<%#Eval("DatePosted") %>' font-underline="false"
                    runat="server" cssclass="edit"></asp:label>*@
            </p>
            <br />
            <br />
            <div class="post entry-content ">
                @*<asp:label id="Label1" text='<%#Eval("QuestionDesc") %>' font-underline="false" runat="server"
                    cssclass="edit"></asp:label>*@
                @foreach (var item in Model)
                {
                    @Html.Label(item.QuestionDesc)
                    break;
                }
            </div>
        </div>
    </div>
    <br />
    <br />
    <br />
    <ul style="background-color: #e4ebf3; text-align: right; background-image: url(http://www.gimptalk.com/public/style_images/master/gradient_bg.png);
        background-repeat: repeat-x; background-position: 40%; font-size: 1em; text-align: right;
        padding: 6px 10px 10px 6px; clear: both;">
        <li>
            <img alt="Add Reply" src="http://www.gimptalk.com/public/style_images/master/comment_add.png" />
            @if (Session["UserName"] != null)
            {
                foreach (var item in Model)
                {
                @Html.ActionLink("Add Reply", "PostReply", "Reply", new { @class = "active", onclick = "javascript:return true;", QuestionID = item.QuestionID, TechID = item.TechID }, null)
                    break;
                }
            }
            else
            {
                foreach (var item in Model)
                {
                @Html.ActionLink("Add Reply", "PostReply", "Reply", new { title = "Please login to post replys", @class = "disabled", onclick = "javascript:return false;", TechID = item.QuestionID })
                    break;
                }
            }
            @*<asp:linkbutton id="lnkpostReply" runat="server" onclick="lnkpostReply_Click" text="Reply"></asp:linkbutton>*@
        </li>
    </ul>
</div>
<br />
<br />
<div>
    @foreach (var item in Model)
    {
        if (item.ReplyUser != null)
        {
        <div class="topic_controls">
            <div class="post_wrap">
                <h3>
                    &nbsp;
                    @if (item.ReplyUser != null)
                    {
                        <span class="author vcard">
                            @Html.ActionLink(item.ReplyUser.ToString(), "Details", "Home", new { Username = item.ReplyUser },
                     null)</span>
                    }
                    <br />
                    @*<asp:linkbutton id="lnkUsername" runat="server" text='<%#Eval("UserName") %>' font-underline="false"></asp:linkbutton>*@
                </h3>
                <div class="authornew">
                    <ul>
                        <li class="avatar">
                            @if (item.ReplyID != null)
                            {
                                <img alt="" src="@Url.Action("ReplyPhoto", "Question_Answer", new { QuestionID = item.ReplyID })"
                    height="100" width="100" class="photo" />
                            }
                            <br />
                        </li>
                    </ul>
                </div>
                <div class="postbody">
                    <p class="postnew">
                        @if (item.date != null)
                        {
                            @Html.Label(item.date.Value.ToString("dd MMMM yyyy - hh:mm tt"))
                        }
                        <br />
                        @*<asp:label id="lblDateposted" text='<%#Eval("DatePosted") %>' font-underline="false"
                    runat="server" cssclass="edit"></asp:label>*@
                    </p>
                    <br />
                    <br />
                    <div class="post
                    entry-content ">
                        @if (item.ReplyMsg != null)
                        {
                            @Html.Label(item.ReplyMsg)
                        }
                        <br />
                    </div>
                    @if (item.ReplyID != null)
                    {
                        <ul style="background-color: #e4ebf3; text-align: right; background-image: url(http://www.gimptalk.com/public/style_images/master/gradient_bg.png);
                            background-repeat: repeat-x; background-position: 40%; font-size: 1em; text-align: right;
                            padding: 6px 10px 10px 6px; clear: both;">
                            <li>
                                <img alt="Add Reply" src="http://www.gimptalk.com/public/style_images/master/comment_add.png" />
                                @*<asp:linkbutton id="lnkpostReply" runat="server" onclick="lnkpostReply_Click" text="Reply"></asp:linkbutton>*@
                                @if (Session["UserName"] == null)
                                {
                                
                                    @Html.ActionLink("Add Reply", "PostReply", "Reply", new { title = "Please login to post replys", @class = "disabled", onclick = "javascript:return false;", TechID = item.QuestionID })
                                
                                }
                                else
                                {
                                    @Html.ActionLink("Add Reply", "PostReply", "Reply", new { @class = "active", onclick = "javascript:return true;", QuestionID = item.QuestionID, TechID = item.TechID }, null)
                                }
                            </li>
                        </ul>
                    }
                </div>
            </div>
        </div>
        }
    }
</div>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

demouser743
Software Developer
India India
I am Dorababu, working as a Software engineer. Web development in Asp.Net with C#, WinForms and MS sql server are the experience tools that I have had for the past 3 years. Yet to work on WCF, WPF, Silverlight and other latest ones.
Follow on   Twitter   Google+

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 15 Feb 2013
Article Copyright 2013 by demouser743
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid