コード例 #1
0
        public LayananModel GetById(string id)
        {
            LayananModel retVal = null;
            string       sSql   = @"
                SELECT      fs_kd_layanan, fs_nm_layanan, fb_popular
                FROM        ta_layanan 
                WHERE       fs_kd_layanan  = @Kode ";

            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    cmd.Parameters.AddWithValue("@Kode", id);
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        dr.Read();
                        retVal           = new LayananModel();
                        retVal.Kode      = dr["fs_kd_layanan"].ToString();
                        retVal.Nama      = dr["fs_nm_layanan"].ToString();
                        retVal.IsPopular = dr["fb_popular"].ToString() == "1" ? true : false;
                    }
                }
            return(retVal);
        }
コード例 #2
0
        public void LayananDal_Update_Succeed_Test()
        {
            LayananModel layanan = new LayananModel
            {
                Kode = "A",
                Nama = "Data1"
            };

            layananDal.Update(layanan);
        }
コード例 #3
0
        public void LayananDal_Insert_Succeed_Test()
        {
            LayananModel layanan = new LayananModel
            {
                Kode = "A",
                Nama = "Data1"
            };

            layananDal.Insert(layanan);
        }
コード例 #4
0
 public IHttpActionResult Save(LayananModel layanan)
 {
     try
     {
         _layananBL.Save(layanan);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #5
0
        public bool IsExist(string id)
        {
            LayananModel dummy = _layananDal.GetById(id);

            if (dummy == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #6
0
        public List <LayananModel> ListData(LayananListDataType listType)
        {
            List <LayananModel> retVal = null;
            string sSql = @"
                    SELECT      fs_kd_layanan, fs_nm_layanan, fb_popular
                    FROM        ta_layanan";

            switch (listType)
            {
            case LayananListDataType.All:
                break;

            case LayananListDataType.Popular:
                sSql += @" 
                        WHERE   fb_popular = 1";
                break;

            case LayananListDataType.NotPopular:
                sSql += @" 
                        WHERE   fb_popular = 0";
                break;

            default:
                break;
            }

            sSql += @"
                ORDER BY    fs_nm_layanan ";

            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        retVal = new List <LayananModel>();
                        while (dr.Read())
                        {
                            LayananModel item = new LayananModel();
                            item.Kode      = dr["fs_kd_layanan"].ToString();
                            item.Nama      = dr["fs_nm_layanan"].ToString();
                            item.IsPopular = dr.GetBoolean(dr.GetOrdinal("fb_popular"));
                            retVal.Add(item);
                        }
                    }
                }
            return(retVal);
        }
コード例 #7
0
        public void JadwalTglBL_ListData2_Succeed_Test()
        {
            //  arrange
            var layanan = new LayananModel {
                Kode = "A"
            };

            //  act
            var dummy = _jadwalTglBL.ListData(layanan, "01-01-2017");

            //  assert
            _jadwalTglDal.AssertWasCalled(x => x.ListData(
                                              Arg <string> .Is.Equal("01-01-2017"),
                                              Arg <LayananModel> .Matches(y => y.Kode == "A")));
        }
コード例 #8
0
        public void LayananDal_GetById_Test()
        {
            //  arrange
            LayananModel layanan = new LayananModel
            {
                Kode      = "A",
                Nama      = "Data1",
                IsPopular = true
            };

            layananDal.Insert(layanan);

            //  act
            layananDal.Delete("A");
        }
コード例 #9
0
        public void Insert(LayananModel layanan)
        {
            string sSql = @"
                INSERT INTO     ta_layanan 
                                (fs_kd_layanan, fs_nm_layanan, fb_popular)
                VALUES          (@KodeLayanan, @NamaLayanan, @IsPopular)";

            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    cmd.Parameters.AddWithValue("@KodeLayanan", layanan.Kode);
                    cmd.Parameters.AddWithValue("@NamaLayanan", layanan.Nama);
                    cmd.Parameters.AddWithValue("@IsPopular", layanan.IsPopular ? 1 : 0);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
コード例 #10
0
        public void LayananBL_Save_Succeed_Test()
        {
            //  arrange
            var layanan = new LayananModel
            {
                Kode = "A",
                Nama = "Data1"
            };

            _layananDal.Stub(x => x.GetById("A")).Return(null);

            //  act
            _layananBL.Save(layanan);

            //  assert
            _layananDal.AssertWasCalled(x => x.Insert(Arg <LayananModel> .Is.Anything));
        }
コード例 #11
0
        public void Update(LayananModel layanan)
        {
            string sSql = @"
                UPDATE      ta_layanan 
                SET         fs_nm_layanan= @NamaLayanan,
                            fb_popular = @IsPopular
                WHERE       fs_kd_layanan = @KodeLayanan";

            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    cmd.Parameters.AddWithValue("@KodeLayanan", layanan.Kode);
                    cmd.Parameters.AddWithValue("@NamaLayanan", layanan.Nama);
                    cmd.Parameters.AddWithValue("@IsPopular", layanan.IsPopular ? 1 : 0);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
コード例 #12
0
        public List <JadwalTglModel> ListData(string tanggal, LayananModel layanan)
        {
            List <JadwalTglModel> retVal = null;

            string sSql = @"
                SELECT      aa.fs_kd_dokter, aa.fs_jam, 
                            aa.fn_durasi, aa.fn_max, aa.fn_booked,
                            ISNULL(bb.fs_nm_dokter, ' ') fs_nm_dokter, 
                            ISNULL(cc.fs_nm_layanan, ' ') fs_nm_layanan
                FROM        ta_jadwal_tgl aa
                LEFT JOIN   ta_dokter bb ON aa.fs_kd_dokter = bb.fs_kd_dokter
                LEFT JOIN   ta_layanan cc ON aa.fs_kd_layanan = cc.fs_kd_layanan
                WHERE       aa.fs_kd_layanan = @KodeLayanan
                        AND aa.fd_tgl_jadwal = @TglJadwal ";

            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    cmd.Parameters.AddWithValue("@KodeLayanan", layanan.Kode);
                    cmd.Parameters.AddWithValue("@TglJadwal", tanggal);
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        retVal = new List <JadwalTglModel>();
                        while (dr.Read())
                        {
                            var item = new JadwalTglModel();
                            item.KodeDokter  = dr["fs_kd_dokter"].ToString();
                            item.KodeLayanan = layanan.Kode;
                            item.TglJadwal   = tanggal;
                            item.Jam         = dr["fs_jam"].ToString();
                            item.NamaDokter  = dr["fs_nm_dokter"].ToString();
                            item.NamaLayanan = dr["fs_nm_layanan"].ToString();
                            item.Durasi      = Convert.ToInt16(dr["fn_durasi"].ToString());
                            item.Max         = Convert.ToInt16(dr["fn_max"].ToString());
                            item.Booked      = Convert.ToInt16(dr["fn_booked"].ToString());
                            retVal.Add(item);
                        }
                    }
                }
            return(retVal);
        }
コード例 #13
0
        public List <JadwalHariModel> ListData(LayananModel layanan)
        {
            List <JadwalHariModel> retVal = null;

            string sSql = @"
                SELECT      aa.fs_kd_dokter, aa.fs_kd_layanan, aa.fn_hari, 
                            aa.fs_jam_mulai, aa.fs_jam_selesai,
                            ISNULL(bb.fs_nm_dokter, ' ') fs_nm_dokter,
                            ISNULL(cc.fs_nm_layanan, ' ') fs_nm_layanan
                FROM        ta_jadwal_hari aa
                LEFT JOIN   ta_dokter bb ON aa.fs_kd_dokter = bb.fs_kd_dokter 
                LEFT JOIN   ta_layanan cc ON aa.fs_kd_layanan = cc.fs_kd_layanan
                WHERE       aa.fs_kd_layanan = @KodeLayanan
                ORDER BY    cc.fs_nm_layanan, bb.fs_nm_dokter ";


            using (SqlConnection conn = new SqlConnection(_connString))
                using (SqlCommand cmd = new SqlCommand(sSql, conn))
                {
                    cmd.Parameters.AddWithValue("@KodeLayanan", layanan.Kode);
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        retVal = new List <JadwalHariModel>();
                        while (dr.Read())
                        {
                            JadwalHariModel item = new JadwalHariModel();
                            item.KodeDokter  = dr["fs_kd_dokter"].ToString();
                            item.NamaDokter  = dr["fs_nm_dokter"].ToString();
                            item.KodeLayanan = dr["fs_kd_layanan"].ToString();
                            item.NamaLayanan = dr["fs_nm_layanan"].ToString();
                            item.Hari        = Convert.ToInt16(dr["fn_hari"].ToString());
                            item.JamMulai    = dr["fs_jam_mulai"].ToString();
                            item.JamSelesai  = dr["fs_jam_selesai"].ToString();
                            retVal.Add(item);
                        }
                    }
                }
            return(retVal);
        }
コード例 #14
0
        public void Save(LayananModel layanan)
        {
            if (layanan.Kode.Trim() == "")
            {
                throw new ArgumentException("KODE LAYANAN kosong");
            }

            if (layanan.Nama.Trim() == "")
            {
                throw new ArgumentException("NAMA LAYANAN kosong");
            }

            if (IsExist(layanan.Kode))
            {
                _layananDal.Update(layanan);
            }
            else
            {
                _layananDal.Insert(layanan);
            }
        }
コード例 #15
0
        public void Save(DokterModel dokter)
        {
            //  cek kode dokter
            if (dokter.Kode.Trim() == "")
            {
                throw new ArgumentException("KODE DOKTER kosong");
            }

            //  cek nama dokter
            if (dokter.Nama.Trim() == "")
            {
                throw new ArgumentException("NAMA DOKTER kosong");
            }

            //  composit: kode layanan
            if (dokter.KodeLayanan.Trim() != "")
            {
                LayananModel layanan = _layananBL.GetById(dokter.KodeLayanan);
                if (layanan == null)
                {
                    throw new ArgumentException("KODE LAYANAN invalid");
                }
                else if (_layananBL.GetById(layanan.Kode).Nama.Trim() == "")
                {
                    throw new ArgumentException("KODE LAYANAN invalid");
                }
            }

            //--save data
            if (!IsExist(dokter.Kode))
            {
                _dokterDal.Insert(dokter);
            }
            else
            {
                _dokterDal.Update(dokter);
            }
        }
コード例 #16
0
        private List <BookingSumHeaderDetailModel> GetData(string kodeLayanan)
        {
            LayananBL          layananBL = new LayananBL();
            DokterBL           dokterBL  = new DokterBL();
            LayananModel       layanan   = layananBL.GetById(kodeLayanan);
            List <DokterModel> dokters   = dokterBL.ListData(kodeLayanan);

            List <BookingSumHeaderDetailModel> retVal = new List <BookingSumHeaderDetailModel>();

            foreach (var item in dokters)
            {
                var item2 = new BookingSumHeaderDetailModel
                {
                    KodeDokter  = item.Kode,
                    NamaDokter  = item.Nama,
                    FilePhoto   = item.PhotoFileName,
                    KodeLayanan = kodeLayanan,
                    NamaLayanan = layanan.Nama,
                    Details     = new List <BookingSumHeaderDetil2Model>()
                };
                retVal.Add(item2);
            }
            return(retVal);
        }
コード例 #17
0
        public void LayananBL_Save_KodeLayananKosong_Test()
        {
            //  arrange
            var layanan = new LayananModel
            {
                Kode = "",
                Nama = "Data1"
            };

            //  act
            string errorMsg = "";

            try
            {
                _layananBL.Save(layanan);
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            //  assert
            Assert.IsTrue(errorMsg == "KODE LAYANAN kosong");
        }
コード例 #18
0
        public void Seed()
        {
            var layananBL = new LayananBL();

            layananBL.Clear();
            //
            var layanan = new LayananModel
            {
                Kode      = "RJ001",
                Nama      = "Umum",
                IsPopular = true
            };

            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ003",
                Nama      = "Anak",
                IsPopular = true
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ002",
                Nama      = "Kandungan Kebidanan",
                IsPopular = true
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ004",
                Nama      = "Penyakit Dalam",
                IsPopular = true
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ005",
                Nama      = "THT",
                IsPopular = false
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ006",
                Nama      = "Kulit Kelamin",
                IsPopular = false
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ007",
                Nama      = "Mata",
                IsPopular = false
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ008",
                Nama      = "Jantung",
                IsPopular = false
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ009",
                Nama      = "Saraf",
                IsPopular = false
            };
            layananBL.Save(layanan);
            //
            layanan = new LayananModel
            {
                Kode      = "RJ010",
                Nama      = "Bedah",
                IsPopular = true
            };
            layananBL.Save(layanan);
        }
コード例 #19
0
        public LayananModel GetById(string id)
        {
            LayananModel retVal = _layananBL.GetById(id);

            return(retVal);
        }
コード例 #20
0
 public List <JadwalHariModel> ListData(LayananModel layanan)
 {
     return(_jadwalHariDal.ListData(layanan));
 }
コード例 #21
0
 public List <JadwalTglModel> ListData(LayananModel layanan, string tanggal)
 {
     return(_jadwalTglDal.ListData(tanggal, layanan));
 }