Example #1
0
        public IEnumerable <KapalData> getDataKapal(ParamKapal paramKapal)
        {
            IEnumerable <KapalData> result = null;

            using (IDbConnection connection = Extension.GetConnection(0))
            {
                try
                {
                    /*  string fnoPermohonan = "";
                     * if (!string.IsNullOrEmpty(NoPermohonan) && NoPermohonan != "7")
                     * {
                     *    fnoPermohonan = "   AND A.NO_PERMOHONAN='" + NoPermohonan + "'  ";
                     * }
                     *
                     *
                     *
                     *
                     */

                    string paramNamaKapal = "";
                    if (!string.IsNullOrEmpty(paramKapal.nama_kapal) && paramKapal.nama_kapal != "string")
                    {
                        paramNamaKapal = " WHERE MKPL_NAMA ='" + paramKapal.nama_kapal + "'";
                    }

                    string paramSearchNamaKapal = "";
                    if (!string.IsNullOrEmpty(paramKapal.search_nama_kapal) && paramKapal.search_nama_kapal != "string")
                    {
                        paramSearchNamaKapal = " WHERE MKPL_NAMA LIKE '" + paramKapal.search_nama_kapal + "%'";
                    }

                    string sql = @"SELECT * FROM (
                                    SELECT 
                                    MKPL_KODE KODE_KAPAL, 
                                    MKPL_NAMA NAMA_KAPAL, 
                                    MKPL_JENIS JENIS_KAPAL,
                                    MKPL_GRT GRT,
                                    MKPL_LOA LOA,
                                    MKPL_BENDERA BENDERA
                                    FROM MASTERDATA.UPKM_KAPAL " +
                                 paramNamaKapal + paramSearchNamaKapal + " AND KD_AKTIF='A'" +
                                 ") WHERE ROWNUM <= 10";

                    result = connection.Query <KapalData>(sql);
                }
                catch (Exception)
                {
                    result = null;
                }
            }
            return(result);
        }
Example #2
0
        public IActionResult getListKapal(ParamKapal data)
        {
            MasKapalDL dal = new MasKapalDL();

            MasKapalModel hasil = new MasKapalModel();

            /**
             * This params is for pagination function
             */
            if (!string.IsNullOrEmpty(data.limit) && data.limit != "string" && !string.IsNullOrEmpty(data.page) && data.page != "string")
            {
                data.page  = data.page;
                data.limit = data.limit;
            }
            else if (!string.IsNullOrEmpty(data.page) && data.page != "string" && string.IsNullOrEmpty(data.limit) && data.limit != "string")
            {
                data.page  = data.page;
                data.limit = "20";
            }
            else if (!string.IsNullOrEmpty(data.limit) && data.limit != "string" && string.IsNullOrEmpty(data.page) && data.page != "string")
            {
                data.page  = "1";
                data.limit = data.limit;
            }
            else
            {
                data.page  = "1";
                data.limit = "20";
            }

            IEnumerable <KapalData> result = dal.getDataKapal(data);

            hasil.message = "Success";
            hasil.status  = "S";
            hasil.count   = result.Cast <Object>().Count();
            hasil.data    = new PagedList <KapalData>(result.ToList(), Convert.ToInt32(data.page), Convert.ToInt32(data.limit));

            return(Ok(hasil));
        }