public int Delete(GrupCustomer obj)
        {
            var result = 0;

            try
            {
                result = _context.db.Delete <GrupCustomer>(obj) ? 1 : 0;
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }
            return(result);
        }
        /// <summary>
        /// Save GrupCustomer record.
        /// </summary>
        /// <param name="obj">GrupCustomer</param>
        /// <returns>Newly inserted grup customer ID</returns>
        public int Save(GrupCustomer obj)
        {
            var result = 0;

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

            return(result);
        }
        public GrupCustomer GetByID(int id)
        {
            GrupCustomer obj = null;

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

            return(obj);
        }
예제 #4
0
        public int Update(GrupCustomer 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));
        }
예제 #5
0
        public int SoftDelete(GrupCustomer obj)
        {
            var result = 0;

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

            return(result);
        }
예제 #6
0
        public GrupCustomer GetByID(int id)
        {
            GrupCustomer obj = null;

            if (_isUseWebAPI)
            {
                // TODO: not implemented yet
                //_unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                //obj = _unitOfWork.GrupCustomerRepository.GetByID(id);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    GrupCustomerRepository repo = new GrupCustomerRepository(context, _log);
                    obj = repo.GetByID(id);
                }
            }

            return(obj);
        }
예제 #7
0
        public int Save(GrupCustomer obj)
        {
            var result = 0;

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

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

            return(result);
        }
        /// <summary>
        /// Delete record pelanggan.
        /// </summary>
        /// <param name="obj">Record pelanggan</param>
        /// <param name="softDelete">Kalau true, jangan hapus recordnya tapi set isAktif=false. Kalau false, delete recordnya.</param>
        /// <returns>Berapa record yg dihapus atau di update.</returns>
        public int Delete(GrupCustomer obj, bool softDelete = true)
        {
            var result = 0;

            try
            {
                if (softDelete)
                {
                    obj.is_aktif = false;
                    result       = Update(obj);
                }
                else
                {
                    result = Delete(obj);
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }