public void RemoveBlog(Blogs blog) { entities.Blogs.Remove(blog); }
void IBlogRepository.AddBlog(Blogs blog) { entities.Blogs.Add(blog); }
public ActionResult Create() { Blogs blog = new Blogs(); CreateBlogViewModel viewModel = new CreateBlogViewModel ( blog, UnitOfWork_.CategoryRepo.GetCategories() ); return View(viewModel); }
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); } }