Exemple #1
0
        public int Save(Kartu obj)
        {
            var result = 0;

            using (IDapperContext context = new DapperContext())
            {
                IUnitOfWork uow = new UnitOfWork(context, _log);
                result = uow.KartuRepository.Save(obj);
            }

            return(result);
        }
Exemple #2
0
        public Kartu GetByID(string id)
        {
            Kartu obj = null;

            using (IDapperContext context = new DapperContext())
            {
                IUnitOfWork uow = new UnitOfWork(context, _log);
                obj = uow.KartuRepository.GetByID(id);
            }

            return(obj);
        }
Exemple #3
0
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _kartu = new Kartu();
            }

            _kartu.nama_kartu = txtNamaKartu.Text;
            _kartu.is_debit   = rdoKartuDebit.Checked;

            var result          = 0;
            var validationError = new ValidationError();

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                if (_isNewData)
                {
                    result = _bll.Save(_kartu, ref validationError);
                }
                else
                {
                    result = _bll.Update(_kartu, ref validationError);
                }

                if (result > 0)
                {
                    Listener.Ok(this, _isNewData, _kartu);

                    if (_isNewData)
                    {
                        base.ResetForm(this);
                        txtNamaKartu.Focus();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    if (validationError.Message.NullToString().Length > 0)
                    {
                        MsgHelper.MsgWarning(validationError.Message);
                        base.SetFocusObject(validationError.PropertyName, this);
                    }
                    else
                    {
                        MsgHelper.MsgUpdateError();
                    }
                }
            }
        }
        public Kartu GetByID(string id)
        {
            Kartu obj = null;

            try
            {
                obj = _context.db.Get <Kartu>(id);
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
        public void DeleteTest()
        {
            var obj = new Kartu
            {
                kartu_id = "cdac4989-433c-4287-8d05-25f3594bd09c"
            };

            var result = _bll.Delete(obj);

            Assert.IsTrue(result != 0);

            var deletedObj = _bll.GetByID(obj.kartu_id);

            Assert.IsNull(deletedObj);
        }
        public int Delete(Kartu obj)
        {
            var result = 0;

            try
            {
                result = _context.db.Delete <Kartu>(obj) ? 1 : 0;
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
Exemple #7
0
        public int Update(Kartu obj, ref ValidationError validationError)
        {
            var validatorResults = _validator.Validate(obj);

            if (!validatorResults.IsValid)
            {
                foreach (var failure in validatorResults.Errors)
                {
                    validationError.Message      = failure.ErrorMessage;
                    validationError.PropertyName = failure.PropertyName;
                    return(0);
                }
            }

            return(Update(obj));
        }
Exemple #8
0
        public int Save(Kartu obj)
        {
            var result = 0;

            try
            {
                var api      = "save";
                var response = RestSharpHelper <OpenRetailWebApiPostResponse> .PostRequest(_apiUrl, api, obj);

                result = Convert.ToInt32(response.Results);
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
Exemple #9
0
        public int Save(Kartu obj)
        {
            var result = 0;

            try
            {
                obj.kartu_id = _context.GetGUID();

                _context.db.Insert <Kartu>(obj);
                result = 1;
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Kartu kartu = new Kartu();

            Karyawan karyawan = new Karyawan();

            karyawan.nama   = "paijo";
            karyawan.status = true;

            if (karyawan.login(kartu))
            {
                Console.WriteLine("mashoook pak eko");
            }
            else
            {
                Console.WriteLine("pakceklik");
            }
            Console.ReadKey();
        }
Exemple #11
0
        public Kartu GetByID(string id)
        {
            Kartu obj = null;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                obj         = _unitOfWork.KartuRepository.GetByID(id);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    obj         = _unitOfWork.KartuRepository.GetByID(id);
                }
            }

            return(obj);
        }
Exemple #12
0
        public int Delete(Kartu obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                result      = _unitOfWork.KartuRepository.Delete(obj);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    result      = _unitOfWork.KartuRepository.Delete(obj);
                }
            }

            return(result);
        }
Exemple #13
0
        public Kartu GetByID(string id)
        {
            Kartu obj = null;

            try
            {
                var api      = string.Format("get_by_id?id={0}", id);
                var response = RestSharpHelper <OpenRetailWebApiGetResponse <Kartu> > .GetRequest(_apiUrl, api).Data;

                if (response.Results.Count > 0)
                {
                    obj = response.Results[0];
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
Exemple #14
0
        public FrmEntryKartu(string header, Kartu kartu, IKartuBll bll)
            : base()
        {
            InitializeComponent();
            ColorManagerHelper.SetTheme(this, this);

            base.SetHeader(header);
            base.SetButtonSelesaiToBatal();
            this._bll   = bll;
            this._kartu = kartu;

            txtNamaKartu.Text = this._kartu.nama_kartu;

            if (this._kartu.is_debit)
            {
                rdoKartuDebit.Checked = true;
            }
            else
            {
                rdoKartuKredit.Checked = true;
            }
        }
Exemple #15
0
        public int Save(Kartu obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                obj.kartu_id = Guid.NewGuid().ToString();

                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                result      = _unitOfWork.KartuRepository.Save(obj);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    result      = _unitOfWork.KartuRepository.Save(obj);
                }
            }

            return(result);
        }
        public void SaveTest()
        {
            var obj = new Kartu
            {
                nama_kartu = "Debit",
                is_debit   = true
            };

            var validationError = new ValidationError();

            var result = _bll.Save(obj, ref validationError);

            Console.WriteLine("Error : " + validationError.Message);

            Assert.IsTrue(result != 0);

            var newObj = _bll.GetByID(obj.kartu_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.kartu_id, newObj.kartu_id);
            Assert.AreEqual(obj.nama_kartu, newObj.nama_kartu);
            Assert.AreEqual(obj.is_debit, newObj.is_debit);
        }
Exemple #17
0
 public bool login(Kartu kartu)
 {
     return(kartu.IsValid(this));
 }