public void SaveTest()
        {
            var obj = new Dropshipper
            {
                nama_dropshipper = "Lacie Kaesmans",
                alamat           = "110 Mosinee Hill",
                kontak           = "Lacie",
                telepon          = "212-367-3754"
            };

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

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.dropshipper_id, newObj.dropshipper_id);
            Assert.AreEqual(obj.nama_dropshipper, newObj.nama_dropshipper);
            Assert.AreEqual(obj.alamat, newObj.alamat);
            Assert.AreEqual(obj.kontak, newObj.kontak);
            Assert.AreEqual(obj.telepon, newObj.telepon);
        }
Ejemplo n.º 2
0
        public int Save(Dropshipper obj)
        {
            var result = 0;

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

            return(result);
        }
Ejemplo n.º 3
0
        public Dropshipper GetByID(string id)
        {
            Dropshipper obj = null;

            using (IDapperContext context = new DapperContext())
            {
                IUnitOfWork uow = new UnitOfWork(context, _log);
                obj = uow.DropshipperRepository.GetByID(id);
            }

            return(obj);
        }
Ejemplo n.º 4
0
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _dropshipper = new Dropshipper();
            }

            _dropshipper.nama_dropshipper = txtDropshipper.Text;
            _dropshipper.alamat           = txtAlamat.Text;
            _dropshipper.telepon          = txtTelepon.Text;

            var result          = 0;
            var validationError = new ValidationError();

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                if (_isNewData)
                {
                    result = _bll.Save(_dropshipper, ref validationError);
                }
                else
                {
                    result = _bll.Update(_dropshipper, ref validationError);
                }

                if (result > 0)
                {
                    Listener.Ok(this, _isNewData, _dropshipper);

                    if (_isNewData)
                    {
                        base.ResetForm(this);
                        txtDropshipper.Focus();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    if (validationError.Message.NullToString().Length > 0)
                    {
                        MsgHelper.MsgWarning(validationError.Message);
                        base.SetFocusObject(validationError.PropertyName, this);
                    }
                    else
                    {
                        MsgHelper.MsgUpdateError();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public Dropshipper GetByID(string id)
        {
            Dropshipper obj = null;

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

            return(obj);
        }
Ejemplo n.º 6
0
        public int Delete(Dropshipper obj)
        {
            var result = 0;

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

            return(result);
        }
        public void DeleteTest()
        {
            var obj = new Dropshipper
            {
                dropshipper_id = "810efc21-9809-4730-b18b-065e7e1b9368"
            };

            var result = _bll.Delete(obj);

            Assert.IsTrue(result != 0);

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

            Assert.IsNull(deletedObj);
        }
        public FrmEntryDropshipper(string header, Dropshipper dropshipper, IDropshipperBll bll)
            : base()
        {
            InitializeComponent();
            ColorManagerHelper.SetTheme(this, this);

            base.SetHeader(header);
            base.SetButtonSelesaiToBatal();
            this._bll         = bll;
            this._dropshipper = dropshipper;

            txtDropshipper.Text = this._dropshipper.nama_dropshipper;
            txtAlamat.Text      = this._dropshipper.alamat;
            txtTelepon.Text     = this._dropshipper.telepon;
        }
Ejemplo n.º 9
0
        public FrmPreviewLabelNotaPenjualan(string header, JualProduk jual)
            : this()
        {
            this.Text            = header;
            this.lblHeader.Text  = header;
            this._log            = MainProgram.log;
            this._pengguna       = MainProgram.pengguna;
            this._profil         = MainProgram.profil;
            this._pengaturanUmum = MainProgram.pengaturanUmum;
            this._jual           = jual;
            this._customer       = this._jual.Customer;
            this._dropshipper    = this._jual.Dropshipper;

            SetLabelNota();
            btnPreviewNota_Click(btnPreviewNota, new EventArgs());
        }
Ejemplo n.º 10
0
        public int Update(Dropshipper 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 Delete(Dropshipper obj)
        {
            var result = 0;

            try
            {
                var api      = "delete";
                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(Dropshipper obj)
        {
            var result = 0;

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

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

            return(result);
        }
Ejemplo n.º 13
0
        public Dropshipper GetByID(string id)
        {
            Dropshipper obj = null;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                obj         = _unitOfWork.DropshipperRepository.GetByID(id);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    obj         = _unitOfWork.DropshipperRepository.GetByID(id);
                }
            }

            return(obj);
        }
Ejemplo n.º 14
0
        public int Delete(Dropshipper obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                result      = _unitOfWork.DropshipperRepository.Delete(obj);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    result      = _unitOfWork.DropshipperRepository.Delete(obj);
                }
            }

            return(result);
        }
        public Dropshipper GetByID(string id)
        {
            Dropshipper obj = null;

            try
            {
                var api      = string.Format("get_by_id?id={0}", id);
                var response = RestSharpHelper <OpenRetailWebApiGetResponse <Dropshipper> > .GetRequest(_apiUrl, api).Data;

                if (response.Results.Count > 0)
                {
                    obj = response.Results[0];
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
Ejemplo n.º 16
0
        public int Save(Dropshipper obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                obj.dropshipper_id = Guid.NewGuid().ToString();

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

            return(result);
        }