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); }
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); }
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); }
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)); }
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); }
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); }
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(); }
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); }
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); }
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); }
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; } }
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); }
public bool login(Kartu kartu) { return(kartu.IsValid(this)); }