public int Save(PembayaranHutangProduk obj, bool isSaveFromPembelian, 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); } } var result = 0; if (_isUseWebAPI) { obj.pembayaran_hutang_produk_id = Guid.NewGuid().ToString(); foreach (var item in obj.item_pembayaran_hutang) { item.item_pembayaran_hutang_produk_id = Guid.NewGuid().ToString(); } _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log); result = _unitOfWork.PembayaranHutangProdukRepository.Save(obj, isSaveFromPembelian); } else { using (IDapperContext context = new DapperContext()) { _unitOfWork = new UnitOfWork(context, _log); result = _unitOfWork.PembayaranHutangProdukRepository.Save(obj, isSaveFromPembelian); } } return(result); }
public int Save(PembayaranHutangProduk obj, bool isSaveFromPembelian, 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); } } var result = 0; using (IDapperContext context = new DapperContext()) { IUnitOfWork uow = new UnitOfWork(context, _log); result = uow.PembayaranHutangProdukRepository.Save(obj, isSaveFromPembelian); } return(result); }