예제 #1
0
 public void RemoveBlog(Blogs blog)
 {
     entities.Blogs.Remove(blog);
 }
예제 #2
0
 void IBlogRepository.AddBlog(Blogs blog)
 {
     entities.Blogs.Add(blog);
 }
예제 #3
0
        public ActionResult Create()
        {
            Blogs blog = new Blogs();

            CreateBlogViewModel viewModel = new CreateBlogViewModel
            (
                blog,
                UnitOfWork_.CategoryRepo.GetCategories()
            );

            return View(viewModel);
        }
예제 #4
0
        public ActionResult Create(Blogs blog)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    blog.PostedBy = User.Identity.Name;
                    blog.DatePosted = DateTime.Now;

                    UnitOfWork_.BlogRepo.AddBlog(blog);
                    UnitOfWork_.BlogRepo.Save();

                    return RedirectToAction("Index");
                }
                else
                {
                    CreateBlogViewModel viewModel = new CreateBlogViewModel
                    (
                        blog,
                        UnitOfWork_.CategoryRepo.GetCategories()
                    );

                    return View(viewModel);
                }


            }
            catch
            {
                CreateBlogViewModel viewModel = new CreateBlogViewModel
                (
                    blog,
                    UnitOfWork_.CategoryRepo.GetCategories()
                );

                return View(viewModel);
            }
        }
예제 #5
0
 public void RemoveBlog(Blogs blog)
 {
     entities.Blogs.Remove(blog);
 }
예제 #6
0
 void IBlogRepository.AddBlog(Blogs blog)
 {
     entities.Blogs.Add(blog);
 }