Ejemplo n.º 1
0
 public ActionResult DeleteBlog(long id, FormCollection collection)
 {
     try
     {
         BlogFactory DeleteBlog = new BlogFactory();
         BlogEntity  Blog       = new BlogEntity();
         Blog = DeleteBlog.GetBlogById(id);
         DataLayer.tblBlog NewBlog = new DataLayer.tblBlog();
         NewBlog.BlogId      = id;
         NewBlog.TopicId     = Blog.TopicId;
         NewBlog.BlogName    = Blog.BlogName;
         NewBlog.BlogHeading = Blog.BlogHeading;
         NewBlog.CreatedDate = Blog.CreatedDate;
         NewBlog.CreatedBy   = Blog.CreatedBy;
         NewBlog.UpdatedDate = DateTime.Now;
         NewBlog.UpdatedBy   = null;
         NewBlog.IsActive    = false; // IsActive will be false in delete record
         DeleteBlog.SaveBlog(NewBlog);
         return(RedirectToAction("Blog"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 2
0
 public ActionResult EditBlog(int id, BlogEntity Blog)
 {
     try
     {
         if (ModelState.IsValid)
         {
             BlogFactory       EditBlog = new BlogFactory();
             DataLayer.tblBlog NewBlog  = new DataLayer.tblBlog();
             ValidationFactory VF       = new ValidationFactory();
             string            Message  = VF.BlogValidity(Blog.BlogName, id);
             if (Message != "Success")
             {
                 ModelState.AddModelError("BlogName", Message);
                 GetTopic();
                 return(View(Blog));
             }
             else
             {
                 NewBlog.BlogId      = id;
                 NewBlog.TopicId     = Blog.TopicId;
                 NewBlog.BlogName    = Blog.BlogName;
                 NewBlog.BlogHeading = Blog.BlogHeading;
                 NewBlog.CreatedDate = Blog.CreatedDate;
                 NewBlog.CreatedBy   = null;
                 NewBlog.UpdatedDate = DateTime.Now;
                 NewBlog.UpdatedBy   = null;
                 NewBlog.IsActive    = Blog.IsActive;
                 EditBlog.SaveBlog(NewBlog);
                 return(RedirectToAction("Blog"));
             }
         }
         else
         {
             return(View(Blog));
         }
     }
     catch
     {
         return(View());
     }
     finally
     {
         GetTopic();
     }
 }
Ejemplo n.º 3
0
 public ActionResult CreateBlog(BlogEntity Blog)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ValidationFactory    VF         = new ValidationFactory();
             BlogFactory          AddBlog    = new BlogFactory();
             DataLayer.tblBlog    NewBlog    = new DataLayer.tblBlog();
             DataLayer.tblChannel NewChannel = new DataLayer.tblChannel();
             string Message = VF.BlogValidity(Blog.BlogName, null);
             if (Message != "Success")
             {
                 ModelState.AddModelError("BlogName", Message);
                 GetTopic();
                 return(View(Blog));
             }
             else
             {
                 NewBlog.BlogName    = Blog.BlogName;
                 NewBlog.BlogHeading = Blog.BlogHeading;
                 NewBlog.TopicId     = Blog.TopicId;
                 NewBlog.CreatedDate = DateTime.Now;
                 NewBlog.CreatedBy   = null;
                 NewBlog.UpdatedDate = null;
                 NewBlog.UpdatedBy   = null;
                 NewBlog.IsActive    = true;
                 AddBlog.SaveBlog(NewBlog);
                 return(RedirectToAction("Blog"));
             }
         }
         else
         {
             GetTopic();
             return(View(Blog));
         }
     }
     catch (Exception Ex)
     {
         GetTopic();
         return(View());
     }
     finally { GetTopic(); }
 }