Ejemplo n.º 1
0
        public virtual ActionResult List(string sidx, string sord, int page, int rows)
        {
            int totalRecords = 0;
            var warehouses   = _mWarehouseRepository.GetPagedWarehouseList(sidx, sord, page, rows, ref totalRecords);
            int pageSize     = rows;
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            var jsonData = new
            {
                total   = totalPages,
                page    = page,
                records = totalRecords,
                rows    = (
                    from warehouse in warehouses
                    select new
                {
                    i = warehouse.Id.ToString(),
                    cell = new string[] {
                        warehouse.Id,
                        warehouse.WarehouseName,
                        warehouse.WarehouseStatus,
                        warehouse.EmployeeId != null?  warehouse.EmployeeId.Id : null,
                        warehouse.EmployeeId != null?  warehouse.EmployeeId.PersonId.PersonFirstName : null,
                        warehouse.CostCenterId != null?  warehouse.CostCenterId.CostCenterName : null,
                        warehouse.CostCenterId != null?  warehouse.CostCenterId.Id : null,
                        GetAccountRef(EnumReferenceTable.Warehouse, warehouse.Id) != null ? GetAccountRef(EnumReferenceTable.Warehouse, warehouse.Id).AccountId.Id : null,
                        GetAccountRef(EnumReferenceTable.Warehouse, warehouse.Id) != null ? GetAccountRef(EnumReferenceTable.Warehouse, warehouse.Id).AccountId.AccountName : null,
                        GetAccountRef(EnumReferenceTable.WarehouseUsing, warehouse.Id) != null ? GetAccountRef(EnumReferenceTable.WarehouseUsing, warehouse.Id).AccountId.Id : null,
                        GetAccountRef(EnumReferenceTable.WarehouseUsing, warehouse.Id) != null ? GetAccountRef(EnumReferenceTable.WarehouseUsing, warehouse.Id).AccountId.AccountName : null,
                        warehouse.AddressId != null?  warehouse.AddressId.AddressLine1 : null,
                        warehouse.AddressId != null?  warehouse.AddressId.AddressLine2 : null,
                        warehouse.AddressId != null?  warehouse.AddressId.AddressLine3 : null,
                        warehouse.AddressId != null?  warehouse.AddressId.AddressPhone : null,
                        warehouse.AddressId != null?  warehouse.AddressId.AddressCity : null,
                        warehouse.WarehouseDesc
                    }
                }).ToArray()
            };


            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }