예제 #1
0
        public int Save(PembayaranPiutangProduk obj, bool isSaveFromPenjualan, 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_piutang_id = Guid.NewGuid().ToString();

                foreach (var item in obj.item_pembayaran_piutang)
                {
                    item.item_pembayaran_piutang_id = Guid.NewGuid().ToString();
                }

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

            return(result);
        }
예제 #2
0
        public int Save(PembayaranPiutangProduk obj, bool isSaveFromPenjualan, 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.PembayaranPiutangProdukRepository.Save(obj, isSaveFromPenjualan);
            }

            return(result);
        }