예제 #1
0
        public async Task <ActionResult> DeleteInfo(int id, string sortOrder = "", int pageNumber = 1)
        {
            ViewBag.PageNumber  = pageNumber;
            ViewBag.CurrentSort = sortOrder;
            string result = "";

            try
            {
                if (ModelState.IsValid)
                {
                    result = await _info.Delete(id);
                }
                else
                {
                    // do business logic
                }
                var allInfo = _info.GetAllInfo(sortOrder);
                var html    = PartialView("~/Views/Partials/_Info.cshtml").RenderToString(allInfo.ToPagedList(pageNumber, 10));
                return(PartialView("~/Views/Partials/_Info.cshtml", allInfo.ToPagedList(pageNumber, 10)));

                if (Request.IsAjaxRequest())
                {
                    return(Json(new { message = html }));
                }
                else
                {
                    return(Json(new { error = "it's not an ajax call", message = html }));
                }
            }
            catch (Exception ex)
            {
                ErrorLog.GetDefault(null).Log(new Error(ex));
                throw;
            }
        }