public IActionResult GetAllState()
        {
            try
            {
                bool   status = false;
                string message;

                List <StateAddResponseModel> data = _stateBusiness.GetAllState();

                if (data != null)
                {
                    if (data.Count == 0)
                    {
                        message = "No State is available";
                        return(Ok(new { status, message }));
                    }
                    else
                    {
                        status  = true;
                        message = "Here is the list of all State";
                        return(Ok(new { status, message, data }));
                    }
                }
                message = "Unable to Fetch the list of State";
                return(Ok(new { status, message }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }
Exemplo n.º 2
0
        public JsonResult GetAllState(DataTableAjaxPostModel model, StateAdvanceSearchViewModel stateAdvanceSearchVM)
        {
            stateAdvanceSearchVM.DataTablePaging.Start  = model.start;
            stateAdvanceSearchVM.DataTablePaging.Length = (stateAdvanceSearchVM.DataTablePaging.Length == 0) ? model.length : stateAdvanceSearchVM.DataTablePaging.Length;
            List <StateViewModel> stateVMList = Mapper.Map <List <State>, List <StateViewModel> >(_stateBusiness.GetAllState(Mapper.Map <StateAdvanceSearchViewModel, StateAdvanceSearch>(stateAdvanceSearchVM)));

            if (stateAdvanceSearchVM.DataTablePaging.Length == -1)
            {
                int totalResult    = stateVMList.Count != 0 ? stateVMList[0].TotalCount : 0;
                int filteredResult = stateVMList.Count != 0 ? stateVMList[0].FilteredCount : 0;
                stateVMList = stateVMList.Skip(0).Take(filteredResult > 10000 ? 10000 : filteredResult).ToList();
            }
            return(Json(new
            {
                // this is what datatables wants sending back
                draw = model.draw,
                recordsTotal = stateVMList.Count != 0 ? stateVMList[0].TotalCount : 0,
                recordsFiltered = stateVMList.Count != 0 ? stateVMList[0].FilteredCount : 0,
                data = stateVMList
            }));
        }