public async Task <IActionResult> Delete(CustomerAddress customerCreditCard)
        {
            var result = await _customerAddressService.Delete(customerCreditCard);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
예제 #2
0
        /// <summary>
        /// Removes addresses deleted in the back office.
        /// </summary>
        /// <param name="customer">
        /// The customer.
        /// </param>
        private void RemoveDeletedAddresses(CustomerDisplay customer)
        {
            var existing = _customerAddressService.GetByCustomerKey(customer.Key);

            var existingAddresses = existing as ICustomerAddress[] ?? existing.ToArray();

            if (!existingAddresses.Any())
            {
                return;
            }

            foreach (var delete in existingAddresses.Where(address => customer.Addresses.All(x => x.Key != address.Key)).ToList())
            {
                _customerAddressService.Delete(delete);
            }
        }
예제 #3
0
        public override void DoOperation()
        {
            try
            { //Validate Reques Header / Constants
                this.baseResponseMessage = ValidateInput();
                if (!this.baseResponseMessage.header.IsSuccess)
                {
                    throw new Exception(this.baseResponseMessage.header.ResponseMessage);
                }
                //Operation
                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region ADD
                    long checkGuid = 0;
                    this.customerAddress = new CustomerAddress
                    {
                        INSERT_USER     = this.request.INSERT_USER,
                        UPDATE_USER     = this.request.UPDATE_USER,
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        ZIPCODE         = this.request.ZIPCODE
                    };
                    //Add Data to Database
                    checkGuid = customerAddressService.Insert(this.customerAddress);

                    this.response = new ResponseCustomerAddress
                    {
                        CUSTOMER_NUMBER = checkGuid,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        COUNTRY         = this.request.COUNTRY,
                        CITY            = this.request.CITY,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkGuid == 0 ? false : true,
                            ResponseCode    = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region GET
                    customerAddress = customerAddressService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER);
                    this.response   = new ResponseCustomerAddress
                    {
                        CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                        CITY            = customerAddress.CITY,
                        COUNTRY         = customerAddress.COUNTRY,
                        DESCRIPTION     = customerAddress.DESCRIPTION,
                        ZIPCODE         = customerAddress.ZIPCODE,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region DELETE
                    this.customerAddress = new CustomerAddress
                    {
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        UPDATE_USER     = this.request.UPDATE_USER
                    };
                    if (customerAddressService.Delete(this.customerAddress))
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = "",
                            COUNTRY         = "",
                            DESCRIPTION     = "",
                            ZIPCODE         = "",
                            header          = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    else
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = false,
                                ResponseCode    = CommonDefinitions.ERROR_MESSAGE,
                                ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR
                            }
                        };
                    }
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region UPDATE
                    this.customerAddress = new CustomerAddress
                    {
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        UPDATE_USER     = this.request.UPDATE_USER
                    };
                    if (customerAddressService.Update(this.customerAddress))
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    else
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = false,
                                ResponseCode    = CommonDefinitions.ERROR_MESSAGE,
                                ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR
                            }
                        };
                    }
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }
예제 #4
0
 /// <summary>
 /// Deletes a single instance of the <see cref="ICustomerAddress"/>
 /// </summary>
 /// <param name="address">
 /// The address to be deleted
 /// </param>
 public void Delete(ICustomerAddress address)
 {
     _customerAddressService.Delete(address);
 }