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")); } }
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; }
protected EntityProxy(EntityId entityId, Client client, ResponseDictionary responseDictionary) { _entityId = entityId; _client = client; _responseDictionary = responseDictionary; this.IsLoaded = false; }
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; } }
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) { }
protected LocationAssociation(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor, bool isHistorical, DateTime?contactCreationDate, ContactType contactType) : base(entityId, responseDictionary, validFor, isHistorical, contactCreationDate) { this.ContactType = contactType; }
internal Association(Association from, ResponseDictionary responseDictionary) : this(from) { _responseDictionary = responseDictionary; }
protected Association(EntityId entityId, ResponseDictionary responseDictionary) : this(entityId, responseDictionary, null, false, null) { }
protected SerializableAssociation(EntityId entityId, ResponseDictionary responseDictionary) : base(entityId, responseDictionary) { }
internal LegalEntityAssociation(Association from, ResponseDictionary responseDictionary) : base(from, responseDictionary) { }
public BusinessAssociation(EntityId entityId, ResponseDictionary responseDictionary) : base(entityId, responseDictionary) { }
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) { }
internal BusinessAssociation(Association from, ResponseDictionary responseDictionary) : base(from, responseDictionary) { }
public LocationAssociation(EntityId entityId, ResponseDictionary responseDictionary) : base(entityId, responseDictionary) { }
internal LocationAssociation(Association from, ResponseDictionary responseDictionary) : base(from, responseDictionary) { }
internal SerializableAssociation(Association from, ResponseDictionary responseDictionary) : base(from, responseDictionary) { }
protected LegalEntityAssociation(EntityId entityId, ResponseDictionary responseDictionary, TimePeriod validFor, bool isHistorical, DateTime?contactCreationDate) : base(entityId, responseDictionary, validFor, isHistorical, contactCreationDate) { }
protected LegalEntityAssociation(EntityId entityId, ResponseDictionary responseDictionary) : base(entityId, responseDictionary) { }