Esempio n. 1
0
 public ActionResult CreateTheme(Theme item)
 {
     if (ModelState.IsValid)
     {
         repository.Themes.AddValue(item);
     }
     return RedirectToAction("Themes");
 }
Esempio n. 2
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();
     }
 }