Beispiel #1
0
        public void Delete(IRSKey key)
        {
            //      INPUT VALIDATION
            if (key is null)
            {
                throw new ArgumentException("RUMAH SAKIT ID empty");
            }

            //      APPLY
            _rsDal.Delete(key);
        }
Beispiel #2
0
        public RSModel GetData(IRSKey key)
        {
            //      INPUT VALIDATION
            if (key is null)
            {
                throw new ArgumentException("RUMAH SAKIT ID empty");
            }

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

            //      RETURN
            return(result);
        }
        public void Delete(IRSKey key)
        {
            var sql = @"
                DELETE
                    OFTA_RS 
                WHERE
                    RSID = @RSID ";

            using (var conn = new SqlConnection(ConnStringHelper.Get()))
                using (var cmd = new SqlCommand(sql, conn))
                {
                    cmd.AddParam("@RSID", key.RSID, SqlDbType.VarChar);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
        public RSModel GetData(IRSKey key)
        {
            RSModel result = null;
            var     sql    = @"
                SELECT
                    aa.RSName, aa.KotaID,
                    ISNULL(bb.KotaName,'') KotaName
                FROM
                    OFTA_RS aa
                    LEFT JOIN OFTA_Kota bb ON aa.KotaID = bb.KotaID
                WHERE
                    RSID = @RSID ";

            using (var conn = new SqlConnection(ConnStringHelper.Get()))
                using (var cmd = new SqlCommand(sql, conn))
                {
                    cmd.AddParam("@RSID", key.RSID, SqlDbType.VarChar);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        dr.Read();
                        result = new RSModel
                        {
                            RSID     = key.RSID,
                            RSName   = dr["RSName"].ToString(),
                            KotaID   = dr["KotaID"].ToString(),
                            KotaName = dr["KotaName"].ToString()
                        };
                    }
                }
            return(result);
        }