public BlogContentModel ConvertBlogContentToModel(blog_content blogContent) { return(new BlogContentModel() { Id = blogContent.blog_content_id, Content = blogContent.content, Title = blogContent.title, Description = blogContent.description }); }
public ActionResult BlogDetail(BlogModel model) { using (var scope = new TransactionScope()) { var blog = _service.GetBlogById(model.Id); if (Equals(blog, null)) { blog = new blog() { blog_id = 0, created_date = ConvertDatetime.GetCurrentUnixTimeStamp() }; } if (!Equals(model.ImageFile, null)) { string fileName = "Blog_" + ConvertDatetime.GetCurrentUnixTimeStamp() + Path.GetExtension(model.ImageFile.FileName); string path = Path.Combine(Server.MapPath("~/Upload"), fileName); model.ImageFile.SaveAs(path); blog.img = fileName; } blog.type = model.Type; _service.SaveBlog(blog); int idx = 0; foreach (var blogContent in model.ContentList) { var content = _service.GetBlogContentById(blogContent.Id); if (Equals(content, null)) { content = new blog_content() { blog_content_id = 0, blog_id = blog.blog_id, language = idx }; } content.title = blogContent.Title; content.description = blogContent.Description; content.content = blogContent.Content; _service.SaveBlogContent(content); idx++; } scope.Complete(); } return(RedirectToAction("Blog")); }
public void SaveBlogContent(blog_content content) { BlogContentRepository.Save(content); }