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); }
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); }
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); }
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); }
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); }
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); }
public MesinKasir GetByID(string id) { MesinKasir obj = null; try { obj = _context.db.Get <MesinKasir>(id); } catch (Exception ex) { _log.Error("Error:", ex); } return(obj); }
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)); }
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; } }
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); }