Esempio n. 1
0
        public KotaModel GetData(IKotaKey key)
        {
            KotaModel result = null;
            var       sql    = @"
                SELECT
                    KotaName
                FROM
                    OFTA_Kota
                WHERE
                    KotaID = @KotaID ";

            using (var conn = new SqlConnection(ConnStringHelper.Get()))
                using (var cmd = new SqlCommand(sql, conn))
                {
                    cmd.AddParam("@KotaID", key.KotaID, SqlDbType.VarChar);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        dr.Read();
                        result = new KotaModel
                        {
                            KotaID   = key.KotaID,
                            KotaName = dr["KotaName"].ToString()
                        };
                    }
                }
            return(result);
        }
Esempio n. 2
0
        public void Delete(IKotaKey key)
        {
            //      INPUT VALIDATION
            if (key is null)
            {
                throw new ArgumentException("KOTA ID empty");
            }

            //      REPO-OP
            _kotaDal.Delete(key);
        }
Esempio n. 3
0
        public KotaModel GetData(IKotaKey key)
        {
            //      INPUT VALIDATION
            if (key is null)
            {
                throw new ArgumentException("KOTA ID empty");
            }

            //      REPO-OP
            var result = _kotaDal.GetData(key);

            //      RETURN
            return(result);
        }
Esempio n. 4
0
        public void Delete(IKotaKey key)
        {
            var sql = @"
                DELETE
                    OFTA_Kota 
                WHERE
                    KotaID = @KotaID ";

            using (var conn = new SqlConnection(ConnStringHelper.Get()))
                using (var cmd = new SqlCommand(sql, conn))
                {
                    cmd.AddParam("@KotaID", key.KotaID, SqlDbType.VarChar);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }