Пример #1
0
        private async Task <ContractViewModel> InitializeModel()
        {
            var carrier = await _contractClient.ListAllCarrier();

            var mga = await _contractClient.ListAllMGA();

            var advisor = await _contractClient.ListAllAdvisor();

            ContractViewModel contractViewModel = new ContractViewModel();

            foreach (var item in carrier)
            {
                contractViewModel.ListEntity.Add(new System.Web.Mvc.SelectListItem {
                    Text = item.BusinessName, Value = "Carrier|" + item.BusinessId
                });
            }
            foreach (var item in mga)
            {
                contractViewModel.ListEntity.Add(new System.Web.Mvc.SelectListItem {
                    Text = item.BusinessName, Value = "MGA|" + item.BusinessId
                });
            }
            foreach (var item in advisor)
            {
                contractViewModel.ListEntity.Add(new System.Web.Mvc.SelectListItem {
                    Text = item.LastName + ", " + item.FirstName, Value = "Advisor|" + item.AdvisorId
                });
            }

            return(contractViewModel);
        }
Пример #2
0
        public async Task <IActionResult> LoadGrid()
        {
            var draw = HttpContext.Request.Form["draw"].FirstOrDefault();
            // Skiping number of Rows count
            var start = Request.Form["start"].FirstOrDefault();
            // Paging Length 10,20
            var length = Request.Form["length"].FirstOrDefault();
            // Sort Column Name
            var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();
            // Sort Column Direction ( asc ,desc)
            var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault();
            // Search Value from (Search box)
            var searchValue = Request.Form["search[value]"].FirstOrDefault();

            //Paging Size (10,20,50,100)
            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int recordsTotal = 0;

            // Getting all Customer data
            var mgadata = await _contractClient.ListAllMGA();

            //total number of rows count
            recordsTotal = mgadata.Count();
            //Paging
            var data = mgadata.Skip(skip).Take(pageSize).ToList();

            //Returning Json Data
            return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }));
        }