Exemplo n.º 1
0
        public JenisLunasModel TryValidate(JenisLunasModel jenisLunas)
        {
            var result = jenisLunas;

            if (jenisLunas == null)
            {
                throw new ArgumentNullException(nameof(jenisLunas));
            }

            if (jenisLunas.JenisLunasID.Trim() == "")
            {
                throw new ArgumentException("JenisLunasID empty");
            }
            if (jenisLunas.JenisLunasName.Trim() == "")
            {
                throw new ArgumentException("JenisLunasName empty");
            }
            if (jenisLunas.JenisBiayaID.Trim() != "")
            {
                var jenisBiaya = _jenisBiayaBL.GetData(jenisLunas.JenisBiayaID);
                if (jenisBiaya == null)
                {
                    throw new ArgumentException("JenisBiayaID invalid");
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public BiayaModel Save(BiayaModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (model.NilaiBiaya <= 0)
            {
                throw new ArgumentException("Nilai Biaya invalid");
            }

            var jenisBiaya = _jenisBiayaBL.GetData(model.JenisBiayaID);

            if (jenisBiaya == null)
            {
                throw new ArgumentException("JenisBiayaID invalid");
            }

            var jenisKas = _jenisKasBL.GetData(model.JenisKasID);

            if (jenisKas == null)
            {
                throw new ArgumentException("JenisKasID invalid");
            }

            if (model.BiayaID.Trim() == "")
            {
                model.BiayaID = GenNewID();
            }

            using (var trans = TransHelper.NewScope())
            {
                //  hapus data lama
                _biayaDal.Delete(model.BiayaID);
                //  simpan data baru
                _biayaDal.Insert(model);

                trans.Complete();
            }

            return(model);
        }
        public IHttpActionResult GetData(string jenisBiayaID)
        {
            var jbtn = new JenisBiayaModel {
                JenisBiayaID = jenisBiayaID
            };

            try
            {
                var result = _jenisBiayaBL.GetData(jbtn);
                if (result is null)
                {
                    return(BadRequest("Data Not Found"));
                }
                return(Ok(result));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
        }