Esempio n. 1
0
        public ActionResult DeleteBlog(int id)
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();

            try
            {
                this.blogRepository.Delete(id);
                return(GetAllBlogs());
            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false;
                ajaxActionReturn.ErrorMessage  = ex.Message;
            }
            return(this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult UpdateBlog(Blog blogData)
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();

            try
            {
                blogData.BlogTime = DateTime.Now;
                this.blogRepository.SaveOrUpdate(blogData);
                return(GetAllBlogs());
            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false;
                ajaxActionReturn.ErrorMessage  = ex.Message;
            }
            return(this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult GetAllBlogs()
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();

            try
            {
                var blogs = this.blogRepository.GetAll().OrderByDescending(t => t.BlogTime);
                ajaxActionReturn.ActionSuccess = true;
                ajaxActionReturn.HtmlResult    = RenderPartialViewToString("BlogsTable", blogs);
            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false;
                ajaxActionReturn.ErrorMessage  = ex.Message;
            }
            return(this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonResult GetAllBlogs()
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();
            try
            {
                var blogs = this.blogRepository.GetAll().OrderByDescending(t => t.BlogTime);
                ajaxActionReturn.ActionSuccess = true;
                ajaxActionReturn.HtmlResult = RenderPartialViewToString("BlogsTable", blogs);
            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false;
                ajaxActionReturn.ErrorMessage = ex.Message;

            }
            return this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet);
        }
Esempio n. 5
0
        public ActionResult DeleteBlog(int id)
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();

            try
            {

                this.blogRepository.Delete(id);
                return GetAllBlogs();

            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false;
                ajaxActionReturn.ErrorMessage = ex.Message;
            }
            return this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        public JsonResult UpdateBlog(Blog blogData)
        {
            AjaxActionReturn ajaxActionReturn = new AjaxActionReturn();

            try
            {
                blogData.BlogTime = DateTime.Now;
                this.blogRepository.SaveOrUpdate(blogData);
                return GetAllBlogs();

            }
            catch (Exception ex)
            {
                ajaxActionReturn.ActionSuccess = false ;
                ajaxActionReturn.ErrorMessage = ex.Message;
            }
            return this.Json(ajaxActionReturn, JsonRequestBehavior.AllowGet);
        }