public ActionResult DetailBlog(int id)
        {
            BlogDao blogDao = new BlogDao();
            Blog    blog    = blogDao.GetById(id);

            return(View(blog));
        }
Beispiel #2
0
        public void Create()
        {
            ResetDatabase();

            AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)];
            BlogDao   blogDao   = (BlogDao)Container[typeof(BlogDao)];
            PostDao   postDao   = (PostDao)Container[typeof(PostDao)];

            Author author = new Author("hamilton verissimo", "hammett", "mypass");
            Blog   blog   = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

            Post post = new Post("My first entry", "This is my first entry", DateTime.Now);

            post.Blog = blog;

            authorDao.Create(author);
            blogDao.Create(blog);
            postDao.Create(post);

            IList posts = postDao.Find();

            Assert.AreEqual(1, posts.Count);

            Post comparisson = (Post)posts[0];

            Assert.AreEqual(post.Title, comparisson.Title);
            Assert.AreEqual(post.Contents, comparisson.Contents);
        }
Beispiel #3
0
        public ActionResult BlogMenu()
        {
            var BlogType = new BlogDao();
            var model    = BlogType.ListNameBlog();

            return(PartialView(model));
        }
Beispiel #4
0
        public void FindBlogPosts()
        {
            ResetDatabase();

            AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)];
            BlogDao   blogDao   = (BlogDao)Container[typeof(BlogDao)];

            Author author = new Author("hamilton verissimo", "hammett", "mypass");
            Blog   blog   = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

            authorDao.Create(author);
            blogDao.Create(blog);

            Post post1 = new Post("My first entry", "This is my first entry", DateTime.Now);

            post1.Blog = blog;
            Post post2 = new Post("My second entry", "This is my second entry", DateTime.Now);

            post2.Blog = blog;

            PostDao postDao = (PostDao)Container[typeof(PostDao)];

            postDao.Create(post1);
            postDao.Create(post2);

            IList posts = postDao.Find(blog);

            Assert.AreEqual(2, posts.Count);
        }
Beispiel #5
0
        /*********SEARCH*********/
        public ActionResult Search(string phrase)
        {
            BlogDao      blogDao = new BlogDao();
            IList <Blog> blogs   = blogDao.SearchBlogs(phrase);

            return(View("Index", blogs));
        }
Beispiel #6
0
        public MainForm(NewBlog newBlog, BlogDao blogDao, PostDao postDao)
        {
            InitializeComponent();

            _newBlog = newBlog;
            _blogDao = blogDao;
            _postDao = postDao;
        }
        // GET: Blog
        public ActionResult Index()
        {
            var blogDao = new BlogDao();

            ViewBag.NewBlog = blogDao.ListBlog(5);



            return(View());
        }
        public ActionResult RenderSide()
        {
            /**
             * Render Side for Detail Index - Reicents Blogs
             */
            int          totalBlogs;
            BlogDao      blogDao = new BlogDao();
            IList <Blog> blogs   = blogDao.GetBlogPaged(3, 1, out totalBlogs);

            return(View(blogs));
        }
        /*********SEARCH*********/
        public ActionResult Search(string phrase)
        {
            BlogDao      blogDao = new BlogDao();
            IList <Blog> blogs   = blogDao.SearchBlogs(phrase);
            KnihovnaUser user    = new KnihovnaUserDao().GetByLogin(User.Identity.Name);

            if (user.Role.Identificator == "blogger" || user.Role.Identificator == "admin")
            {
                return(View("BlogEdited", blogs));
            }

            return(View("Index", blogs));
        }
        public void CommonStatelessUsage()
        {
            container.Register(Component.For <BlogDao>().Named("blogdao"));

            BlogDao dao = container.Resolve <BlogDao>("blogdao");

            dao.CreateBlog("my blog");

            IList blogs = dao.ObtainBlogsStateless();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Count);
        }
Beispiel #11
0
        public void CommonUsage()
        {
            container.AddComponent("blogdao", typeof(BlogDao));

            BlogDao dao = (BlogDao)container["blogdao"];

            dao.CreateBlog("my blog");

            IList blogs = dao.ObtainBlogs();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Count);
        }
Beispiel #12
0
        public ActionResult Index(int?pageBlog)
        {
            int itemsOnPageBlog = 9;
            int pgB             = pageBlog.HasValue ? pageBlog.Value : 1;
            int totalBlogs;

            BlogDao      blogDao = new BlogDao();
            IList <Blog> blogs   = blogDao.GetBlogPaged(itemsOnPageBlog, pgB, out totalBlogs);

            ViewBag.PagesBlog       = (int)Math.Ceiling((double)totalBlogs / (double)itemsOnPageBlog);
            ViewBag.CurrentPageBlog = pgB;

            return(View(blogs));
        }
        public ActionResult UpdateBlog(Blog blog)
        {
            try
            {
                BlogDao blogDao = new BlogDao();

                blogDao.Update(blog);

                TempData["message-success"] = "Blog " + blog.Header + " byl upraven";
            }
            catch (Exception)
            {
                throw;
            }

            return(RedirectToAction("Index", "Blog"));
        }
        public ActionResult AddBlog(Blog blog)
        {
            if (ModelState.IsValid)
            {
                BlogDao blogDao = new BlogDao();
                blogDao.Create(blog);

                TempData["message-success"] = "Blog byl uspesne pridan";
            }
            else
            {
                //vracam View Create sa svim podatcima koje je vec ispunio
                return(View("CreateBlog", blog));
            }

            return(RedirectToAction("Index")); //presmerovani
        }
Beispiel #15
0
        public void TestAddBlog()
        {
            BlogDao.Delete("0fd98278b1a549638556ca029b1dffe8");
            BlogDao.Delete("3b5df9babcc64ec4a49599e10272c365");

            var blog = new Blog();

            blog.Summary    = "";
            blog.CreateTime = DateTime.Now;
            blog.ID         = Guid.NewGuid().ToString("N");

            BlogDao.Create(blog);

            blog.Summary = "<p>&nbsp;&nbsp;直接抢劫了现成的模板,在网络上挖上一个专属自己的坑。</p>";
            BlogDao.Update(blog);

            BlogDao.Delete(blog.ID);
        }
Beispiel #16
0
        public void CreateAuthorAndBlog()
        {
            ResetDatabase();

            AccountService service = (AccountService)Container[typeof(AccountService)];

            Author author = new Author("hamilton verissimo", "hammett", "mypass");
            Blog   blog   = new Blog("hammett's blog", "Description", "default", author);

            service.CreateAccountAndBlog(blog);

            AuthorDao dao = (AuthorDao)Container[typeof(AuthorDao)];

            Assert.AreEqual(1, dao.Find().Count);
            BlogDao blogdao = (BlogDao)Container[typeof(BlogDao)];

            Assert.AreEqual(1, blogdao.Find().Count);
        }
        public ActionResult DeleteBlog(int id)
        {
            try
            {
                BlogDao blogDao = new BlogDao();
                Blog    blog    = blogDao.GetById(id);


                blogDao.Delete(blog);

                TempData["message-success"] = "Blog " + blog.Header + " byl smazan";
            }
            catch (Exception e)
            {
                throw;
            }

            return(RedirectToAction("Index"));
        }
Beispiel #18
0
        public void FindAll()
        {
            ResetDatabase();

            AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)];
            BlogDao   blogDao   = (BlogDao)Container[typeof(BlogDao)];

            Author author = new Author("hamilton verissimo", "hammett", "mypass");
            Blog   blog1  = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);
            Blog   blog2  = new Blog("hammett's personal blog", "more thoughts.. ugh!", "default", author);

            authorDao.Create(author);
            blogDao.Create(blog1);
            blogDao.Create(blog2);

            IList blogs = blogDao.Find();

            Assert.AreEqual(2, blogs.Count);
        }
        public ActionResult Index(int?pageBlog)
        {
            int itemsOnPageBlog = 9;
            int pgB             = pageBlog.HasValue ? pageBlog.Value : 1;
            int totalBlogs;

            BlogDao      blogDao = new BlogDao();
            IList <Blog> blogs   = blogDao.GetBlogPaged(itemsOnPageBlog, pgB, out totalBlogs);

            ViewBag.PagesBlog       = (int)Math.Ceiling((double)totalBlogs / (double)itemsOnPageBlog);
            ViewBag.CurrentPageBlog = pgB;

            KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name);

            if (user.Role.Identificator == "blogger" || user.Role.Identificator == "admin")
            {
                return(View("BlogEdited", blogs));
            }

            return(View(blogs));
        }
Beispiel #20
0
        public void Create()
        {
            ResetDatabase();

            AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)];
            BlogDao   blogDao   = (BlogDao)Container[typeof(BlogDao)];

            Author author = new Author("hamilton verissimo", "hammett", "mypass");
            Blog   blog   = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

            authorDao.Create(author);
            blogDao.Create(blog);

            IList blogs = blogDao.Find();

            Assert.AreEqual(1, blogs.Count);

            Blog comparisson = (Blog)blogs[0];

            Assert.AreEqual(blog.Name, comparisson.Name);
            Assert.AreEqual(blog.Description, comparisson.Description);
            Assert.AreEqual(blog.Theme, comparisson.Theme);
        }
Beispiel #21
0
 public BlogCRUDService(IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     _blogDao = new BlogDao(unitOfWork);
 }
Beispiel #22
0
 public BlogService(AuthorDao authorDao, BlogDao blogDao, PostDao postDao)
 {
     _authorDao = authorDao;
     _blogDao   = blogDao;
     _postDao   = postDao;
 }
Beispiel #23
0
 public BlogImpl()
 {
     _blogDao = new BlogDao();
 }
        public ReadOnlyTransactionsService(ISessionManager sessionManager,  BlogDao dao)
		{
			this.dao = dao;
			this.sessionManager = sessionManager;
		}
Beispiel #25
0
 public static void AddBlog(Blog blog)
 {
     BlogDao.Create(blog);
 }
Beispiel #26
0
 public static void UpdateBlog(Blog blog)
 {
     BlogDao.Update(blog);
 }
Beispiel #27
0
 public BlogControllerCreatorSubscriber(BlogDao blogDao, ControllerTree controllerTree)
 {
     _blogDao        = blogDao;
     _controllerTree = controllerTree;
 }
Beispiel #28
0
 public static void DeleteBloe(string id)
 {
     BlogDao.Delete(id);
 }
Beispiel #29
0
 public static Blog GetBlog(string id)
 {
     return(BlogDao.GetBlog(id));
 }
Beispiel #30
0
 public static List <Blog> GetBlogs()
 {
     return(BlogDao.GetAllBlogs());
 }
Beispiel #31
0
        public NewBlog(BlogDao blogDao)
        {
            InitializeComponent();

            _blogDao = blogDao;
        }