public IHttpActionResult MembershipLoad(MembershipDataInputModel membership)
        {
            try
            {
                //pass the data to the service to insert into the database
                string message = string.Empty;

                var mappedModel = Mapper.Map <MembershipDataInputModel, MembershipDataInput>(membership);

                NameAndAddressParameter nameAndAddress = new NameAndAddressParameter
                {
                    NameAndAddress = membership.CustNameAndAddress
                };
                var membershipProcess = new MembershipProcess(null, _membershipService, _mciRequestService, _logger, nameAndAddress);

                List <MembershipOutput> result = new List <MembershipOutput>();
                result.Add(new MembershipOutput()
                {
                    MembershipData = membershipProcess.UpdateMembershipData(mappedModel)
                });
                return(Ok(result));
            }
            catch (Exception exception)
            {
                if (_logParameterValue)
                {
                    _logger.Error($"MembershipLoad: ErrorTag: {ErrorTagProvider.ErrorTagDatabase} --  {exception.Message}");

                    _logger.Error(
                        $"Parameters MembershipLoad:- Name=FirstName={membership.CustNameAndAddress.FirstName}, LastName={membership.CustNameAndAddress.Surname}, Dob={membership.CustNameAndAddress.Dob}, " +
                        $" Address=AddresLine1={ membership.CustNameAndAddress.Address.Address1 ?? ""}, AddressLine2={membership.CustNameAndAddress.Address.Address2 ?? ""}, AddressLine3={membership.CustNameAndAddress.Address.Address3 ?? ""}, " +
                        $" AddressLine4={membership.CustNameAndAddress.Address.Address4 ?? ""}, PostCode={membership.CustNameAndAddress.Address.Postcode ?? ""}");
                }
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message)));
            }
        }
コード例 #2
0
        /// <summary>
        /// keyValue now an instance parameter to allow for Autofac DI instantiation of strategy classes...
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public object[] Execute(KeyValueParameter keyValue)
        {
            _keyValue = keyValue;
            int processedObject = 0;

            object[] output = new object[_keyValue.ResponseRequestedItems.Count];

            bool customerFound = true;

            try
            {
                if (_keyValue.ReturnMe.CustomerKeys != null)
                {
                    // AE : Feb 18 - Used injected key Process instance from DI container
                    // var customerKeyProcess = new CustomerKeyProcess(_keyValue, _mciRequestService,
                    //     _clientScopeService, _logger);
                    output[processedObject] = _customerKeyProcess.Process(_keyValue);

                    customerFound = _customerKeyProcess.CustomerFound;
                    processedObject++;
                }

                if (customerFound)
                {
                    if (_keyValue.ReturnMe.MailingHistory != null)
                    {
                        MailingHistoryProcess mailingHistoryProcess = new MailingHistoryProcess(
                            _nameAndAddress, _mailingHistoryService, _mciRequestService, _clientScopeService,
                            _logger, _keyValue);
                        output[processedObject] = mailingHistoryProcess.ProcessForKeyValue();
                        processedObject++;
                    }


                    // CITCS-17 - Request includes an aggregated view of Membership Permissions
                    if (_keyValue.ReturnMe.MembershipFlags.Required)
                    {
                        // IKeyValueReadStrategyPart mebmershipFlagsReader = new KeyValueMembershipFlagsReadStrategyPart(
                        //    _keyValue, _permissionService, _mciRequestService, _membershipService, _logger
                        //     );
                        output[processedObject] = _membershipFlagsKeyValueReader.Process(_keyValue);
                        processedObject++;
                    }

                    // As per Sam Sheperd 19/09/2017 - We should not process any permissions data request in /Customer
                    // so I have commented this out and asked Jay to remove from the documentation

                    //if (_keyValue.ReturnMe.Permissions != null && _keyValue.ReturnMe.Permissions.Required)
                    //{
                    //    var permissionProcess = new ProcessPermission(_keyValue, _permissionService,
                    //        _mciRequestService, _logger, _nameAndAddress);
                    //    output[_processedObject] = permissionProcess.ProcessPermissionFromKeyValue();
                    //    _processedObject++;
                    //}

                    if (_keyValue.ReturnMe.Membership != null && _keyValue.ReturnMe.Membership.Required)
                    {
                        var membershipProcess = new MembershipProcess(_keyValue, _membershipService,
                                                                      _mciRequestService, _logger);

                        var memberObj = membershipProcess.ProcessMembershipWithKeyValue();

                        if (!membershipProcess.CustomerFound)
                        {
                            output[processedObject] = HttpStatusCode.NotFound;
                        }
                        else
                        {
                            output[processedObject] = memberObj;
                        }
                        processedObject++;
                        if (memberObj != null && (memberObj.GetType() != typeof(NoAccessToMembership)))
                        {
                            //need to resize the array to accommodate the membershipstatus, membershipCancelReason and MembershipStatusReason values
                            //that are retrieved from GMD to populate the frontend e.g AFE
                            Array.Resize(ref output, output.Length + 1);
                            // output[processedObject] = membershipProcess.GetMembershipOptionsData();

                            // GITCS-1 : Retire above membership process method
                            // _membershipOptionsReader =
                            //    _nameAndAddressReaders[NameAndAddressStrategyReaderImplementations.MembershipOptionsReaderPart];
                            output[processedObject] = _membershipOptionsReader.Process(_nameAndAddress, null);

                            processedObject++;
                        }
                    }

                    if (_keyValue.ReturnMe.CustomerDetails != null && _keyValue.ReturnMe.CustomerDetails.Required)
                    {
                        CustomerInfo info = new CustomerInfo();

                        // var customerDetails = new CustomerDetailsProcess(_keyValue, _customerDetailsService, _logger);
                        info.CustomerDetails = _customerDetailsProcess.Process(_keyValue);
                        // AE : 15 Feb 18 : Call process interface from DI container

                        if (info.CustomerDetails == null)
                        {
                            output[processedObject] = HttpStatusCode.NotFound;
                        }
                        else
                        {
                            output[processedObject] = info;
                        }
                        processedObject++;
                    }

                    if (_keyValue.ReturnMe.TravelSummary != null && _keyValue.ReturnMe.TravelSummary.Required)
                    {
                        var travelSummary = new CustomerMatchProcess(_nameAndAddress, _customerMatchService, _travelSummaryService, _logger);
                        output[processedObject] = travelSummary.TravelSummaryProcess(int.Parse(_keyValue.KeyValue.Value));
                        processedObject++;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("KeyValuePairStrategy: " + "ErrorTag: " + ErrorTagProvider.ErrorTag + " -- " + ex.Message, ex);
                throw new Exception(ex.Message);
            }

            return(output);
        }