Example #1
0
        public ResponseModel ProcessExpensivePayment(PaymentModel request)
        {
            try
            {
                //call integration.
                var result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.ExpensiveUrl, request);

                //expensive gateway is not avalable use cheap gateway.
                if (string.IsNullOrEmpty(result?.ResponseCode) || result == null)
                {
                    result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.CheapUrl, request);
                }

                //map payment model to db object
                var dbModel = _paymentProfile.MapPayment(request);

                //save to database.
                _baseRepo.SavePayment(dbModel, result);


                return(result);
            }
            catch (Exception ex)
            {
                Trace.TraceInformation($"An error occurred, {ex.Message}");
                return(ResponseDictionary.ProvideResponse("06"));
            }
        }
Example #2
0
        public ResponseModel ProcessPayment(PaymentModel request)
        {
            try
            {
                //call integration.
                var result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.CheapUrl, request);

                //map payment model to db object
                var dbModel = _paymentProfile.MapPayment(request);
                if (dbModel == null)
                {
                    return(ResponseDictionary.ProvideResponse("06"));
                }

                //save to database.
                _baseRepo.SavePayment(dbModel, result);

                return(result);
            }
            catch (Exception ex)
            {
                Trace.TraceInformation($"An error occurred, {ex.Message}");
                return(ResponseDictionary.ProvideResponse("06"));
            }
        }
        public ResponseModel ProcessPayment(PaymentModel request)
        {
            try
            {
                request.CreditCardNumber = request.CreditCardNumber.Replace(" ", "").Trim();
                if (request.Amount < appSettings.Value.CheapAmount)
                {
                    //call cheap service
                    return(_cheapPaymentGateway.ProcessPayment(request));
                }
                if (request.Amount >= appSettings.Value.ExpensiveAmountMin && request.Amount <= appSettings.Value.ExpensiveAmountMax)
                {
                    //call expensive service
                    return(_expensivePaymentGateway.ProcessExpensivePayment(request));
                }

                if (request.Amount > appSettings.Value.PremiumAmount)
                {
                    //premium service.
                    return(_premiumPaymentService.ProcessPremiumPayment(request));
                }

                return(ResponseDictionary.ProvideResponse("04"));
            }
            catch (Exception ex)
            {
                Trace.TraceInformation($"An error occurred, {ex.Message}");
                return(ResponseDictionary.ProvideResponse("06"));
            }
        }
        public ResponseModel ProcessPremiumPayment(PaymentModel request)
        {
            int count  = 1;
            var result = new ResponseModel();

            try
            {
                //iterate for 3 times if service is not responding ..
                //the loop breaks if the response is successful
                for (int i = 1; i <= 3; i++)
                {
                    //call integration.
                    result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.PremiumUrl, request);
                    if (result?.ResponseCode == "00")
                    {
                        break;
                    }
                }

                //map payment model to db object
                var dbModel = _paymentProfile.MapPayment(request);


                //save to database.
                _baseRepo.SavePayment(dbModel, result);


                return(result);
            }
            catch (Exception ex)
            {
                Trace.TraceInformation($"An error occurred, {ex.Message}");
                return(ResponseDictionary.ProvideResponse("06"));
            }
        }
 public Response(Client client, List <T> results, ResponseDictionary dictionary, ResponseMessages messages)
 {
     _client     = client;
     _results    = results;
     _dictionary = dictionary;
     _messages   = messages;
 }
Example #6
0
 protected EntityProxy(EntityId entityId, Client client, ResponseDictionary responseDictionary)
 {
     _entityId           = entityId;
     _client             = client;
     _responseDictionary = responseDictionary;
     this.IsLoaded       = false;
 }
Example #7
0
        public virtual Response <IPerson> Decode(Stream stream, Client client)
        {
            using (var sr = new StreamReader(stream))
            {
                var json           = sr.ReadToEnd();
                var personResponse = JsonConvert.DeserializeObject <PersonResponse>(json, new EntityConverter());

                // now construct a Response<IPerson> from this
                var keys = personResponse.ResultKeys;
                var list = personResponse
                           .Dictionary
                           .Values
                           .ToList()
                           .Where(x => x.Id.IsPerson && keys.Contains(x.Id.Key))
                           .Select(x => x as IPerson)
                           .ToList();

                var messages = personResponse.ResponseMessages;
                var dict     = new ResponseDictionary(client);
                foreach (var v in personResponse.Dictionary.Values)
                {
                    v.ResponseDictionary = dict;
                    // this could be any type of base entity.
                    if (v.Id.IsPerson)
                    {
                        dict.Add(v as IPerson);
                    }
                    else if (v.Id.IsBusiness)
                    {
                        dict.Add(v as IBusiness);
                    }
                    else if (v.Id.IsLocation)
                    {
                        dict.Add(v as ILocation);
                    }
                    else if (v.Id.IsPhone)
                    {
                        dict.Add(v as IPhone);
                    }
                }

                foreach (var p in list)
                {
                    foreach (var a in p.Associations)
                    {
                        a.ResponseDictionary = dict;
                    }
                    if (p.BestLocationAssociation != null)
                    {
                        p.BestLocationAssociation.ResponseDictionary = dict;
                    }
                }

                var response = new Response <IPerson>(client, list, dict, messages);
                return(response);
            }
        }
        static ResponseDictionary GetDictionary(Client client)
        {
            var dict = new ResponseDictionary(client);

            dict.Add(_person);
            dict.Add(_business);
            dict.Add(_phone);
            dict.Add(_location);
            return(dict);
        }
        public virtual Response<IPerson> Decode(Stream stream, Client client)
        {
            using (var sr = new StreamReader(stream))
            {
                var json = sr.ReadToEnd();
                var personResponse = JsonConvert.DeserializeObject<PersonResponse>(json, new EntityConverter());

                // now construct a Response<IPerson> from this
                var keys = personResponse.ResultKeys;
                var list = personResponse
                    .Dictionary
                    .Values
                    .ToList()
                    .Where(x=>x.Id.IsPerson && keys.Contains(x.Id.Key))
                    .Select(x => x as IPerson)
                    .ToList();

                var messages = personResponse.ResponseMessages;
                var dict = new ResponseDictionary(client);
                foreach (var v in personResponse.Dictionary.Values)
                {
                    v.ResponseDictionary = dict;
                    // this could be any type of base entity.
                    if (v.Id.IsPerson)
                    {
                        dict.Add(v as IPerson);
                    }
                    else if (v.Id.IsBusiness)
                    {
                        dict.Add(v as IBusiness);
                    }
                    else if (v.Id.IsLocation)
                    {
                        dict.Add(v as ILocation);
                    }
                    else if (v.Id.IsPhone)
                    {
                        dict.Add(v as IPhone);
                    }

                }

                foreach (var p in list)
                {
                    foreach (var a in p.Associations)
                    {
                        a.ResponseDictionary = dict;
                    }
                }

                var response = new Response<IPerson>(client, list, dict, messages);
                return response;

            }
        }
Example #10
0
        protected Association(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor, bool isHistorical,
                              DateTime?contactCreationDate)
        {
            EntityId            = entityId;
            _responseDictionary = responseDictionary;
            ValidFor            = validFor;
            IsHistorical        = isHistorical;
            ContactCreationDate = contactCreationDate;

            ValidateEntityIdType();
        }
        public void MakeEntity()
        {
            _associatedPhone = new Phone(_associatedPhoneId);
            var dict = new ResponseDictionary(null);

            dict.Add(_associatedPhone);
            _entity = new Person(_entityId)
            {
                BusinessAssociations = null,
                LocationAssociations = new List <LocationAssociation>(),
                PhoneAssociations    = new List <PhoneAssociation>
                {
                    new PhoneAssociation(_associatedPhoneId, dict)
                }
            };
        }
 public PersonAssociation(Association from, ResponseDictionary responseDictionary)
     : base(from, responseDictionary)
 {
 }
Example #13
0
 protected LocationAssociation(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor,
                               bool isHistorical, DateTime?contactCreationDate, ContactType contactType)
     : base(entityId, responseDictionary, validFor, isHistorical, contactCreationDate)
 {
     this.ContactType = contactType;
 }
Example #14
0
 internal Association(Association from, ResponseDictionary responseDictionary)
     : this(from)
 {
     _responseDictionary = responseDictionary;
 }
Example #15
0
 protected Association(EntityId entityId, ResponseDictionary responseDictionary)
     : this(entityId, responseDictionary, null, false, null)
 {
 }
Example #16
0
		protected SerializableAssociation(EntityId entityId, ResponseDictionary responseDictionary)
			: base(entityId, responseDictionary)
		{
			
		}
Example #17
0
 internal LegalEntityAssociation(Association from, ResponseDictionary responseDictionary)
     : base(from, responseDictionary)
 {
 }
Example #18
0
 public BusinessAssociation(EntityId entityId, ResponseDictionary responseDictionary)
     : base(entityId, responseDictionary)
 {
 }
Example #19
0
 public BusinessAssociation(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor,
                            bool isHistorical, DateTime?contactCreationDate)
     : base(entityId, responseDictionary, validFor, isHistorical, contactCreationDate)
 {
 }
 internal PhoneAssociation(Association from, ResponseDictionary responseDictionary)
     : base(from, responseDictionary)
 {
 }
Example #21
0
 internal BusinessAssociation(Association from, ResponseDictionary responseDictionary)
     : base(from, responseDictionary)
 {
 }
Example #22
0
 public LocationAssociation(EntityId entityId, ResponseDictionary responseDictionary)
     : base(entityId, responseDictionary)
 {
 }
Example #23
0
 internal LocationAssociation(Association from, ResponseDictionary responseDictionary)
     : base(from, responseDictionary)
 {
 }
Example #24
0
		internal SerializableAssociation(Association from, ResponseDictionary responseDictionary)
			: base(from, responseDictionary)
		{
			
		}
Example #25
0
 protected LegalEntityAssociation(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor,
                                  bool isHistorical, DateTime?contactCreationDate)
     : base(entityId, responseDictionary, validFor, isHistorical, contactCreationDate)
 {
 }
Example #26
0
 protected LegalEntityAssociation(EntityId entityId, ResponseDictionary responseDictionary)
     : base(entityId, responseDictionary)
 {
 }