Beispiel #1
0
        /// <summary>
        /// Deletes a <see cref="IGatewayProviderSettings"/>
        /// </summary>
        /// <param name="gatewayProviderSettings"></param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IGatewayProviderSettings gatewayProviderSettings, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                Deleting.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderSettings), this);
            }

            // delete associated methods
            switch (gatewayProviderSettings.GatewayProviderType)
            {
            case GatewayProviderType.Payment:
                var paymentMethods = _paymentMethodService.GetPaymentMethodsByProviderKey(gatewayProviderSettings.Key).ToArray();
                if (paymentMethods.Any())
                {
                    _paymentMethodService.Delete(paymentMethods);
                }
                break;

            case GatewayProviderType.Shipping:
                var shippingMethods = _shipMethodService.GetShipMethodsByProviderKey(gatewayProviderSettings.Key).ToArray();
                if (shippingMethods.Any())
                {
                    _shipMethodService.Delete(shippingMethods);
                }
                break;

            case GatewayProviderType.Taxation:
                var taxMethods = _taxMethodService.GetTaxMethodsByProviderKey(gatewayProviderSettings.Key).ToArray();
                if (taxMethods.Any())
                {
                    _taxMethodService.Delete(taxMethods);
                }
                break;

            case GatewayProviderType.Notification:
                var notificationMethods =
                    _notificationMethodService.GetNotifcationMethodsByProviderKey(gatewayProviderSettings.Key).ToArray();
                if (notificationMethods.Any())
                {
                    _notificationMethodService.Delete(notificationMethods);
                }
                break;
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateGatewayProviderRepository(uow))
                {
                    repository.Delete(gatewayProviderSettings);
                    uow.Commit();
                }
            }
            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderSettings), this);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _paymentService.Delete(id);

            if (result.IsSuccess)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Beispiel #3
0
        public ActionResult Delete(int id)
        {
            try
            {
                _paymentMethodService.Delete(id);
                _paymentMethodService.SaveChanges();

                return(Content("1"));
            }
            catch (Exception)
            {
                return(Content("0"));
            }
        }
        public async Task <IHttpActionResult> Delete([FromODataUri] int PaymentMethodID)
        {
            var item = await _service.FindAsync(PaymentMethodID);

            if (item == null)
            {
                return(NotFound());
            }

            item.ObjectState = ObjectState.Deleted;

            _service.Delete(item);
            await _unitOfWorkAsync.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult <PaymentMethodDetail_PaymentMethodDTO> > Delete([FromBody] PaymentMethodDetail_PaymentMethodDTO PaymentMethodDetail_PaymentMethodDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            PaymentMethod PaymentMethod = ConvertDTOToEntity(PaymentMethodDetail_PaymentMethodDTO);

            PaymentMethod = await PaymentMethodService.Delete(PaymentMethod);

            PaymentMethodDetail_PaymentMethodDTO = new PaymentMethodDetail_PaymentMethodDTO(PaymentMethod);
            if (PaymentMethod.IsValidated)
            {
                return(PaymentMethodDetail_PaymentMethodDTO);
            }
            else
            {
                return(BadRequest(PaymentMethodDetail_PaymentMethodDTO));
            }
        }