Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>@ViewBag.Title - Forum</title>
- <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
- <meta name="viewport" content="width=device-width" />
- @Styles.Render("~/Content/css")
- @Scripts.Render("~/bundles/modernizr")
- </head>
- <body>
- <header>
- <div class="content-wrapper">
- <div class="float-left">
- <p class="site-title"> <img src="~/images/id_logo.png" /></p>
- </div>
- <div class="float-right">
- <section id="login">
- @Html.Partial("_LoginPartial")
- </section>
- <nav>
- <ul id="menu">
- <li>@Html.ActionLink("Home", "Index", "Home")</li>
- <li>@Html.ActionLink("Forums", "Index", "Forum")</li>
- <li>@Html.ActionLink("About", "About", "Home")</li>
- <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
- <li>@Html.ActionLink("Avatar", "SelectAvatar", "Avatar")</li>
- @Html.Action("Avatar", "Layout")
- </ul>
- </nav>
- </div>
- </div>
- </header>
- <div id="body">
- @RenderSection("featured", required: false)
- <section class="content-wrapper main-content clear-fix">
- @RenderBody()
- </section>
- </div>
- <footer>
- <div class="content-wrapper">
- <div class="float-left">
- <p>© @DateTime.Now.Year - ID</p>
- </div>
- </div>
- </footer>
- @Scripts.Render("~/bundles/jquery")
- @Scripts.Render("~/bundles/jqueryval")
- @RenderSection("scripts", required: false)
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>@ViewBag.Title - Forum</title>
- @Styles.Render("~/Content/css")
- @Scripts.Render("~/bundles/modernizr")
- </head>
- <body>
- <div class="navbar navbar-inverse navbar-fixed-top">
- <div class="container">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"><</span>
- <span class="icon-bar"></span>
- </button>
- @Html.Raw(@Html.ActionLink("[replacetext]", "Index", "Home",
- new { area = "" },
- new { @class = "navbar-brand" })
- .ToHtmlString().Replace("[replacetext]",
- "<img src="/images/forum.jpg" alt="QA Forum logo" />"))
- </div>
- <div class="navbar-collapse collapse ">
- <ul class="nav navbar-nav">
- <li>@Html.ActionLink("Home", "Index", "Home")</li>
- <li>@Html.ActionLink("Forums", "Index", "Forum")</li>
- <li>@Html.ActionLink("Threads", "Index", "Thread")</li>
- <li>@Html.ActionLink("Posts", "Index", "Post")</li>
- <li>@Html.ActionLink("About", "About", "Home")</li>
- <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
- <li>@Html.ActionLink("Avatar", "SelectAvatar", "Avatar")</li>
- <li>@Html.ActionLink("Admin", "Index", "Admin")</li>
- @Html.Action("Avatar", "Layout")
- </ul>
- @Html.Partial("_LoginPartial")
- </div>
- </div>
- </div>
- <div class="container body-content">
- @RenderBody()
- <hr />
- <footer>
- <p>© @DateTime.Now.Year - ID</p>
- </footer>
- </div>
- @Scripts.Render("~/bundles/jquery")
- @Scripts.Render("~/bundles/jqueryval")
- @Scripts.Render("~/bundles/bootstrap")
- @RenderSection("scripts", required: false)
- </body>
- </html>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using LbForum.Models;
- using LbForum.Resources;
- namespace LbForum.Controllers
- {
- public class AvatarController : Controller
- {
- private IStateRepository stateRepository = null;
- public AvatarController()
- : this(new SessionStateRepository())
- {
- }
- public AvatarController(IStateRepository sessionStateRepository)
- {
- this.stateRepository = sessionStateRepository;
- }
- //
- // GET: /Avatar/
- public ActionResult SelectAvatar()
- {
- var avatarUtilities = new AvatarUtilities();
- ViewBag.AvatarList = avatarUtilities.GetAllAvatars();
- ViewBag.RememberAvatar = stateRepository.GetForumUserState().RememberAvatar;
- return View();
- }
- public ActionResult PersistChosenAvatar(string avatarName)
- {
- ForumUserState forumUserState = stateRepository.GetForumUserState();
- forumUserState.AvatarFileName = avatarName;
- forumUserState.PersistAvatar(forumUserState.RememberAvatar);
- return RedirectToAction("Index", "Home");
- }
- public ActionResult RememberAvatar(bool chkRemember)
- {
- ForumUserState forumUserState = stateRepository.GetForumUserState();
- // button logic true keeps avatar data in cookie false doesn't
- if (chkRemember == true)
- {
- forumUserState.RememberAvatar = true;
- forumUserState.PersistAvatar(true);
- }
- else
- {
- forumUserState.RememberAvatar = false;
- forumUserState.PersistAvatar(false);
- }
- return RedirectToAction("SelectAvatar", "Avatar");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement