Esempio n. 1
0
        public IHttpActionResult ViewDestinationMasterByPage(int max, int page, string sort_col, string sort_dir, string search = null)
        {
            Paged_ACRF_DestinationMasterModel objList = new Paged_ACRF_DestinationMasterModel();

            try
            {
                objList = objDestVM.ListDestinationMasterByPage(max, page, search, sort_col, sort_dir);
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }

            return(Ok(new { results = objList }));
        }
Esempio n. 2
0
        public Paged_ACRF_DestinationMasterModel ListDestinationMasterByPage(int max, int page, string search, string sort_col, string sort_dir)
        {
            Paged_ACRF_DestinationMasterModel  objPaged = new Paged_ACRF_DestinationMasterModel();
            List <ACRF_DestinationMasterModel> objList  = new List <ACRF_DestinationMasterModel>();

            try
            {
                if (search == null)
                {
                    search = "";
                }
                int startIndex = max * (page - 1);

                string sqlstr = "ACRF_GetDestinationMasterByPage";

                var connection = gConnection.Connection();
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlstr, connection);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@startRowIndex", startIndex);
                cmd.Parameters.AddWithValue("@pageSize", max);
                cmd.Parameters.AddWithValue("@search", search);
                cmd.Parameters.AddWithValue("@sort_col", sort_col);
                cmd.Parameters.AddWithValue("@sort_dir", sort_dir);
                SqlDataReader sdr = cmd.ExecuteReader();

                while (sdr.Read())
                {
                    ACRF_DestinationMasterModel tempobj = new ACRF_DestinationMasterModel();
                    tempobj.Id             = Convert.ToInt32(sdr["Id"].ToString());
                    tempobj.CityCode       = sdr["CityCode"].ToString();
                    tempobj.CityName       = sdr["CityName"].ToString();
                    tempobj.CountryCode    = sdr["CountryCode"].ToString();
                    tempobj.CountryName    = sdr["CountryName"].ToString();
                    tempobj.TimeDifference = sdr["TimeDifference"].ToString();
                    tempobj.CustomAirport  = sdr["CustomAirport"].ToString();
                    tempobj.AirportName    = sdr["AirportName"].ToString();
                    tempobj.ISDCode        = sdr["ISDCode"].ToString();
                    tempobj.Currency       = sdr["Currency"].ToString();
                    tempobj.State          = sdr["State"].ToString();
                    tempobj.IATAArea       = sdr["IATAArea"].ToString();
                    tempobj.CreatedBy      = sdr["CreatedBy"].ToString();
                    tempobj.CreatedOn      = Convert.ToDateTime(sdr["CreatedOn"].ToString());
                    objList.Add(tempobj);
                }
                sdr.Close();
                objPaged.ACRF_DestinationMasterModelList = objList;


                sqlstr = "select count(*) as cnt from ACRF_DestinationMaster where CityCode like @search ";
                cmd.Parameters.Clear();
                cmd.CommandText = sqlstr;
                cmd.Connection  = connection;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@search", '%' + @search + '%');
                sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    objPaged.PageCount = Convert.ToInt32(sdr["cnt"].ToString());
                }


                connection.Close();
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }
            return(objPaged);
        }