示例#1
0
        /// <summary>
        /// Implementation with a generic return type to allow caller to return what type is required
        /// </summary>
        /// <typeparam name="TR"></typeparam>
        /// <param name="membershipDataInput"></param>
        /// <param name="membershipAction"></param>
        /// <returns></returns>
        protected TR1 UpdateOrCancelMembershipDetails <TR1>(
            MembershipDataInput membershipDataInput,
            MembershipActionType membershipAction = MembershipActionType.Unknown) where TR1 : MembershipDetails
        {
            TR1 updatedMembershipdetails = null;

            string message = string.Empty;

            try
            {
                var customerId = UpdatedOrCancelMembership_Worker(membershipDataInput, membershipAction, ref message);

                // Get return membership details instance via a new Get db call using the customer_id -
                // This will return an instance of the requested TR1 return type (MembershipDetails
                // or MembershipDetailsV2) depending on if we have been called from a V1 or V2 route.
                updatedMembershipdetails      = _membershipdataAccess.GetMembershipDetails <string, TR1>(customerId);
                updatedMembershipdetails.Info = message;
                // return updatedMembershipdetails;
            }
            catch (DatabaseException ex)
            {
                throw new DatabaseException(ex.Message);
            }
            catch (ParameterProcessException ex)
            {
                throw new PreprocessingException(ex.Message);
            }
            catch (Exception ex)
            {
                // _logger.Error("UpdateMembershipData : ErrorTag: " + ErrorTagProvider.ErrorTag + " -- " + ex.Message, ex);
                throw new Exception(ex.Message);
            }

            return(updatedMembershipdetails);
        }
示例#2
0
        /// <summary>
        /// Fetch Membership  details for customer
        /// Refactored logic from MembershipProcess.GetMembershipFromNameAndAddress()
        /// </summary>
        /// <param name="nameAndAddressParameter">NameAndAddress to identify customer</param>
        /// <param name="customerId">Customer Id used in preference to the above if passed</param>
        /// <returns></returns>
        public object Process(NameAndAddressParameter nameAndAddressParameter, int?customerId)
        {
            if (nameAndAddressParameter.AccessControl.ModuleAccess.Find(x => x.HasAccess && x.Key == GroupCode.MEMB) == null)
            {
                NoAccessToMembership message = new NoAccessToMembership();
                message.Message = "You dont' have access for Membership data.";
                return(message);
            }

            var membershipOutputData = new MembershipOutput();

            try
            {
                // Use any Customer Id passed else use NameAddr lookup
                var pkey = customerId ?? _mciRequestDataAccess.GetPersistantKey(nameAndAddressParameter.NameAndAddress);

                if (pkey > 0)
                {
                    _logger.Info("Pkey Found " + pkey);
                    nameAndAddressParameter.ReturnMe.Membership.CustomerId = pkey.Value.ToString();
                    var membershipDetails = _membershipDataAccess.GetMembershipDetails(pkey.Value.ToString());

                    membershipOutputData.MembershipData = membershipDetails;

                    if (string.IsNullOrEmpty(membershipOutputData.MembershipData.ActivationId) &&
                        string.IsNullOrEmpty(membershipOutputData.MembershipData.EncryptedActivationId))
                    {
                        IDictionary <string, string> output =
                            _membershipDataAccess.CreateMembership(nameAndAddressParameter?.ReturnMe?.Membership);

                        membershipOutputData.MembershipData.ActivationId = output["ActivationId"];
                        membershipOutputData.MembershipData =
                            _membershipDataAccess.GetMembershipDetails(membershipOutputData.MembershipData.ActivationId);
                    }
                }
                else
                {
                    return(HttpStatusCode.NotFound);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("GetMembershipFromNameAndAddress : ErrorTag: " + ErrorTagProvider.ErrorTagDatabase + " -- " + ex.Message, ex);

                if (_logParameterValues)
                {
                    _logger.Error(
                        $"Parameters GetMembershipFromNameAndAddress:- Name=FirstName={nameAndAddressParameter.NameAndAddress.FirstName}, LastName={nameAndAddressParameter.NameAndAddress.Surname}, Dob={nameAndAddressParameter.NameAndAddress.Dob}, " +
                        $"Address=AddresLine1={nameAndAddressParameter.NameAndAddress.Address.Address1}, AddressLine2={nameAndAddressParameter.NameAndAddress.Address.Address2}, AddressLine3={nameAndAddressParameter.NameAndAddress.Address.Address3}, " +
                        $"AddressLine4={nameAndAddressParameter.NameAndAddress.Address.Address4}, PostCode={nameAndAddressParameter.NameAndAddress.Address.Postcode}");
                }

                throw new Exception(ex.Message);
            }
            return(membershipOutputData);
        }
        public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
        {
            string body = actionContext.Request.Content.ReadAsStringAsync().Result;
            MembershipCancellationParameterModel model = new MembershipCancellationParameterModel();

            model = JsonConvert.DeserializeObject <MembershipCancellationParameterModel>(body);

            // Get current membership to calidate existing status ..
            _membershipDataAccess =
                (IMembershipDataAccess)
                (actionContext.ControllerContext.Configuration.DependencyResolver as AutofacWebApiDependencyResolver)
                .GetService(typeof(IMembershipDataAccess));

            MembershipDetails membershipDetails =
                _membershipDataAccess.GetMembershipDetails <long, MembershipDetails>(model.MembershipNo ?? default(long));

            // Call new Generic DA method
            if (membershipDetails.MembershipNo.HasValue)
            {
                model.OriginalStatus = membershipDetails.MembershipStatus;
            }
            // GITCS-9 - cancellation reason
            model.ValidMembershipCancellationReasons =
                _membershipDataAccess.GetMembershipOptions("MEMBERSHIP_CANCEL_REASON").Where(mo => mo.CodeList == "MEMBERSHIP_CANCEL_REASON");

            var validator = new MembershipCancellationParameterModelValidator();
            var result    = validator.Validate(model);

            foreach (var e in result.Errors)
            {
                bindingContext.ModelState.AddModelError(e.PropertyName, e.ErrorMessage);
            }
            bindingContext.Model = model;
            return(true);
        }
示例#4
0
        private MembershipDetails GetMembershipDetails(int pKey)
        {
            MembershipDetails details = _membershipDataAccess.GetMembershipDetails(pKey);

            return(details);
        }
        public MembershipDetails GetMembershipDetails(int custRefId)
        {
            var membershipData = _dataAccess.GetMembershipDetails(custRefId);

            return(membershipData);
        }