예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult AddEditPost(int postId = -1)
        {
            try
            {
                Post model = null;
                if (postId == -1)
                {
                    model             = new Post();
                    ViewBag.Categoris = new SelectList(_blogRepository.Categories(), "Id", "Name");
                    ViewBag.Tags      = new MultiSelectList(_blogRepository.Tags(), "Id", "Name");
                }
                else
                {
                    model             = _blogRepository.GetPostbyId(postId, _userStatistics.UserId);
                    ViewBag.Categoris = new SelectList(_blogRepository.Categories(), "Id", "Name", model.Category.Id);
                    ViewBag.Tags      = new MultiSelectList(_blogRepository.Tags(), "Id", "Name", model.Tags.Select(a => a.Id).ToList());
                }


                return(PartialView("../Blog/_AddEdit_Post", model));
            }

            catch (Exception ex)
            {
                //CatchException.CatchTheException(ex);
                throw;
            }
            finally
            {
            }
        }
예제 #2
0
 public WidgetViewModel(IBlogComponent blogRepository)
 {
     Categories = blogRepository.Categories();
     Tags = blogRepository.Tags();
     LatestPosts = blogRepository.Posts(0, 10);
 }
예제 #3
0
 public WidgetViewModel(IBlogComponent blogRepository)
 {
     Categories  = blogRepository.Categories();
     Tags        = blogRepository.Tags();
     LatestPosts = blogRepository.Posts(0, 10);
 }