public void editBlog(BlogEntity blogEntity)
        {
            try
            {
                blog blogObj = Decorator.getBlog(blogEntity);
                db.Entry(blogObj).State = EntityState.Modified;
                db.SaveChanges();
                BlogKeywords blogKeywordsObj = new BlogKeywords();
                BlogKeywordsEntity blogKeywords = blogKeywordsObj.getBlogKeywordsListByBlogId(blogObj.Id);

                blogKeywords.Page_Type = blogObj.Name;
                blogKeywords.Page_Keywords = blogEntity.Page_Keywords;
                blogKeywords.Page_Description = blogEntity.Page_Description;
                blogKeywords.IsDeleted = false;
                if (blogKeywords.Id != 0)
                {
                    blogKeywordsObj.editBlogKeywords(blogKeywords);
                }
                else
                {
                    blogKeywordsObj.createBlogKeywords(blogKeywords);
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteTrace(ex);
            }
        }
 public BlogEntity createBlog(BlogEntity blogEntity)
 {
     try
     {
         blog blogObj = Decorator.getBlog(blogEntity);
         blogObj.CreateDate = DateTime.Now;
         blogObj.IsPublished = false;
         db.blogs.Add(blogObj);
         db.SaveChanges();
         BlogKeywords blogKeywordsObj = new BlogKeywords();
         BlogKeywordsEntity blogKeywords = new BlogKeywordsEntity();
         blogKeywords.Page_Id = blogObj.Id;
         blogKeywords.Page_Type = blogObj.Name;
         blogKeywords.Page_Keywords = blogEntity.Page_Keywords;
         blogKeywords.Page_Description = blogEntity.Page_Description;
         blogKeywords.IsDeleted = false;
         blogKeywordsObj.createBlogKeywords(blogKeywords);
         return Decorator.getBlogEntity(blogObj);
     }
     catch (Exception ex)
     {
         ApplicationLog.WriteTrace(ex);
         return null;
     }
 }
 public BlogEntity Add(BlogEntity item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return blogObject.createBlog(item);
 }
 // GET: Blogs/Create
 public ActionResult Create()
 {
     if (!Request.IsAuthenticated)
     {
         return RedirectToAction("Login", "Account");
     }
     //ViewBag.BlogType = blogTyperepo.GetAll();
     var model = new BlogEntity();
     model.Blog_TypeList = blogTyperepo.GetAll();
     return View(model);
 }
        public bool Update(BlogEntity item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // TO DO : Code to update record into database
            blogObject.editBlog(item);
            return true;
        }
 public static blog getBlog(BlogEntity blogObj)
 {
     blog blog = new blog();
     blog.Id = blogObj.Id;
     blog.Blog_Id = blogObj.Blog_Id;
     blog.Blog_type_Id = blogObj.Blog_type_Id;
     blog.CreateDate = blogObj.CreateDate;
     blog.UpdatedDate = blogObj.UpdatedDate;
     blog.Description = HttpUtility.HtmlEncode( blogObj.Description);
     blog.Blog_short_Content =HttpUtility.HtmlEncode(blogObj.BlogShortContent);
     blog.Name =HttpUtility.HtmlEncode( blogObj.Name);
     blog.Page_Keywords = HttpUtility.HtmlEncode(blogObj.Page_Keywords);
     blog.Page_Description =HttpUtility.HtmlEncode(blogObj.Page_Description);
     blog.IsDeleted = blogObj.IsDeleted;
     blog.IsPublished = blogObj.IsPublished;
     return blog;
 }
        public void sendmail(BlogEntity blog)
        {
            var allblogType = blogTypeRepo.GetAll();
            string str = "";
            foreach (var obj in allblogType)
            {
                if (str != "")
                    str = str + ",";
                str = str + obj.Id;

            }
            var alluserList = userRepo.GetAll();
            var appUrl = WebConfigurationManager.AppSettings["AppUrl"].ToString() + blog.Id.ToString() + "/" + blog.Name.ToSeoUrl();
            foreach (var user in alluserList)
            {
                var desc="firstcrazydeveloper.com --  Abhishek Kumar, First Crazy Developer";
                var mailBody = PopulateBody(user.User_Name, blog.Name, appUrl, desc);
                SendHtmlFormattedEmail(user.User_Email, blog.Name, mailBody);
            }
        }
 public ActionResult Create(BlogEntity blog)
 {
     try
     {
         if (!Request.IsAuthenticated)
         {
             return RedirectToAction("Login", "Account");
         }
         // TODO: Add insert logic here
         blog.IsDeleted = false;
         blog.CreateDate = DateTime.Now;
         blog.UpdatedDate = DateTime.Now;
         blog.Blog_Id =Convert.ToString( Guid.NewGuid());
         var updateBlog=repo.Add(blog);
         return RedirectToAction("Index");
     }
     catch(Exception ex)
     {
         ApplicationLog.WriteTrace(ex);
         var model = new BlogEntity();
         model.Blog_TypeList = blogTyperepo.GetAll();
         return View(model);
     }
 }
        public ActionResult Edit(BlogEntity blog)
        {
            try
            {

                if (!Request.IsAuthenticated)
                {
                    return RedirectToAction("Login", "Account");
                }
                // TODO: Add update logic here

                if (ModelState.IsValid)
                {

                    blog.IsDeleted = blog.IsDeleted == null ? false : blog.IsDeleted;
                    blog.UpdatedDate =DateTime.Now ;
                    blog.Blog_type_Id = blog.Blog_type_Id == null ? 0 : blog.Blog_type_Id;

                    repo.Update(blog);
                    return RedirectToAction("Index");
                }
                blog.Blog_TypeList = blogTyperepo.GetAll();
                return View(blog);
            }
            catch(Exception ex)
            {
                ApplicationLog.WriteTrace(ex);
                blog.Blog_TypeList = blogTyperepo.GetAll();
                return View(blog);
            }
        }
 public void editBlog(BlogEntity blogEntity)
 {
     blogsObj.editBlog(blogEntity);
 }
 public BlogEntity createBlog(BlogEntity blogEntity)
 {
     return blogsObj.createBlog(blogEntity);
 }