Exemplo n.º 1
0
 /// <summary>
 /// The news viewer.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="entry">
 /// The entry.
 /// </param>
 /// <returns>
 /// The <see cref="IHtmlString"/>.
 /// </returns>
 public static IHtmlString NewsViewer(this HtmlHelper context, News entry)
 {
     var html = string.Format(
         "<div class=\"span12 well well-large\">" + "<h2>{0}</h2>" + "<p>{1}</p>" + "<p>{2}</p>"
         + "<i class=\"divider\"></i>" + "<p>" + "<a class=\"btn\" href=\"/Home/Default/{3}\">View details &raquo;</a>" + "</p></div>",
         entry.Name,
         entry.NewsContent,
         entry.Date.Value.ToLongDateString() ?? string.Empty,
         entry.ID);
     return context.Raw(html);
 }
Exemplo n.º 2
0
        public void NewsViewer()
        {
            News ent = new News()
                            {
                                ID = 1,
                                Date = DateTime.Now,
                                Name = "Test",
                                NewsContent = "<i>Hello world!</i>"
                            };

            var html = string.Format(
                    "<div class=\"span12 well well-large\">" + "<h2>{0}</h2>" + "<p>{1}</p>" + "<p>{2}</p>"
                    + "<i class=\"divider\"></i>" + "<p>" + "<a class=\"btn\" href=\"/Home/Default/{3}\">View details &raquo;</a>" + "</p></div>",
                ent.Name,
                ent.NewsContent,
                ent.Date.Value.ToLongDateString() ?? "",
                ent.ID);
            Assert.IsTrue(html == (new HtmlHelper<News>(new ViewContext(), new ViewPage())).NewsViewer(ent).ToHtmlString());
        }
Exemplo n.º 3
0
 public void TestForumFunctionality()
 {
     using (DatabaseEntities context = new DatabaseEntities())
     {
         News newsItm = new News { Date = DateTime.Now, ID = 356, Name = "Test", NewsContent = "Testing" };
         context.News.Add(newsItm);
         Theme newTheme = new Theme
         {
             Created_on = DateTime.Now,
             ID = (new Random((int)DateTime.Now.Ticks)).Next(),
             Name = "Test Theme",
             Description = "Hello World",
             Subgroup = "All"
         };
         Topic newTopic = new Topic()
         {
             Created_on = DateTime.Now,
             Description = "Hello world topic",
             ID = (new Random((int)DateTime.Now.Ticks)).Next(),
             Name = "Test Topic",
             Theme = newTheme.ID
         };
         Message newMessage = new Message()
         {
             Created_on = DateTime.Now,
             ID = (new Random((int)DateTime.Now.Ticks)).Next(),
             Text = "hello",
             Topic = newTopic.ID
         };
         context.Themes.Add(newTheme);
         context.Topics.Add(newTopic);
         context.Messages.Add(newMessage);
         context.SaveChanges();
         Assert.IsTrue(context.Themes.Count(x => x.ID == newTheme.ID) > 0);
         Assert.IsTrue(context.Topics.Count(x => x.ID == newTopic.ID) > 0);
         Assert.IsTrue(context.Messages.Count(x => x.ID == newMessage.ID) > 0);
         context.Themes.Remove(newTheme);
         context.Topics.Remove(newTopic);
         context.Messages.Remove(newMessage);
         context.News.Remove(newsItm);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void TestNewsAndUsrTblWriting()
 {
     using (DatabaseEntities context = new DatabaseEntities())
     {
         News entity = new News { Date = DateTime.Now, ID = 123456, Name = "Hello", NewsContent = "World" };
         context.News.Add(entity);
         context.SaveChanges();
         context.News.Remove(entity);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public ActionResult Index(string message)
 {
     News test = new News { ID = 1, Date = DateTime.Now, Name = "Test", NewsContent = message };
     return Json(test, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 6
0
 //
 // GET: /AJAX/
 public ActionResult Index()
 {
     News test = new News { ID = 1, Date = DateTime.Now, Name = "Test", NewsContent = "Hello World"};
     return Json(test, JsonRequestBehavior.AllowGet);
 }