예제 #1
0
        public void SaveTest()
        {
            var obj = new MesinKasir
            {
                pengguna_id = "00b5acfa-b533-454b-8dfd-e7881edd180f",
                tanggal     = DateTime.Today,
                saldo_awal  = 200000
            };

            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.mesin_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.mesin_id, newObj.mesin_id);
            Assert.AreEqual(obj.pengguna_id, newObj.pengguna_id);
            Assert.AreEqual(obj.tanggal, newObj.tanggal);
            Assert.AreEqual(obj.saldo_awal, newObj.saldo_awal);
        }
예제 #2
0
        public MesinKasir GetByID(string id)
        {
            MesinKasir obj = null;

            using (IDapperContext context = new DapperContext())
            {
                _unitOfWork = new UnitOfWork(context, _log);
                obj         = _unitOfWork.MesinRepository.GetByID(id);
            }

            return(obj);
        }
예제 #3
0
        public int Update(MesinKasir obj)
        {
            var result = 0;

            using (IDapperContext context = new DapperContext())
            {
                _unitOfWork = new UnitOfWork(context, _log);
                result      = _unitOfWork.MesinRepository.Update(obj);
            }

            return(result);
        }
예제 #4
0
        public int Save(MesinKasir obj)
        {
            var result = 0;

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

            return(result);
        }
예제 #5
0
        public void DeleteTest()
        {
            var obj = new MesinKasir
            {
                mesin_id = "6870dec2-3f4b-4952-9174-d6d40f254573"
            };

            var result = _bll.Delete(obj);

            Assert.IsTrue(result != 0);

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

            Assert.IsNull(deletedObj);
        }
예제 #6
0
        public int Update(MesinKasir obj)
        {
            var result = 0;

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

            return(result);
        }
예제 #7
0
        public MesinKasir GetByID(string id)
        {
            MesinKasir obj = null;

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

            return(obj);
        }
예제 #8
0
        public int Save(MesinKasir 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(Save(obj));
        }
예제 #9
0
        private void SimpanSaldoAwal(string penggunaId, int saldoAwal)
        {
            IMesinKasirBll mesinBll = new MesinKasirBll(_log);

            var obj = new MesinKasir
            {
                pengguna_id = penggunaId,
                saldo_awal  = saldoAwal
            };

            var result = mesinBll.Save(obj);

            if (result > 0)
            {
                MainProgram.mesinId = obj.mesin_id;
            }
        }
예제 #10
0
        public int Save(MesinKasir obj)
        {
            var result = 0;

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

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

            return(result);
        }