public JsonResult GetWriters(GridSettings grid)
        {
            if (!grid.IsSearch)
            {
                return(null);
            }

            int totalRecords;
            var data = GetData(grid, out totalRecords);

            //var listVm = Mapper.Map<IEnumerable<Order>, IEnumerable<OrderFormModel>>(data);
            //if (listVm == null) return Json(null);

            var pageSize   = grid.PageSize;
            var totalPages = (int)Math.Ceiling(totalRecords / (float)pageSize);

            var jsonData = new
            {
                total   = totalPages,
                page    = grid.PageIndex,
                records = totalRecords,
                //rows = JQGridConvert.GetJQGridRows(listVm).ToArray()
                rows = JQGridConvert.GetJQGridRowsWithEntity <Writer, WriterFormModel>(data).ToArray()
            };


            //convert to JSON and return to client
            //return Json(jsonData, JsonRequestBehavior.AllowGet);
            var jsonResult = Json(jsonData, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Example #2
0
        public async Task <JsonResult> GetEmailings(GridSettings grid)
        {
            //if (!grid.IsSearch) return null;

            int totalRecords;
            var data = GetData(grid, out totalRecords);

            foreach (var emailingDetail in data)
            {
                var emailingInfo = await _emailingService.GetInfoMessage(emailingDetail.EmailId);

                if (emailingInfo == null)
                {
                    continue;
                }
                emailingDetail.State  = emailingInfo.State;
                emailingDetail.Opens  = emailingInfo.Opens;
                emailingDetail.Clicks = emailingInfo.Clicks;
            }

            var pageSize   = grid.PageSize;
            var totalPages = (int)Math.Ceiling(totalRecords / (float)pageSize);

            var jsonData = new
            {
                total   = totalPages,
                page    = grid.PageIndex,
                records = totalRecords,
                //rows = JQGridConvert.GetJQGridRows(listVm).ToArray()
                rows = JQGridConvert.GetJQGridRowsWithEntity <EmailingDetail, EmalingStatisticFormModel>(data).ToArray()
            };

            //convert to JSON and return to client
            //return Json(jsonData, JsonRequestBehavior.AllowGet);
            var jsonResult = Json(jsonData, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }