/// <summary> /// Creates the lead quote. /// </summary> /// <param name="leadId">The lead identifier.</param> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> CreateLeadQuote(int leadId, CreateLeadQuoteRequest request) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.Lead + LeadServiceOperation.CreateLeadQuote(leadId), contentPost); //return JsonConvert.DeserializeObject<APIResponse>(await response.Content.ReadAsStringAsync()); if (response.IsSuccessStatusCode) { var leadQuote = JsonConvert.DeserializeObject <LeadQuoteResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(leadQuote, HttpStatusCode.Created)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'CreateLeadQuote()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Gets the leads. /// </summary> /// <param name="leadParameters">The lead parameters.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public async Task <APIResponse> GetLeads(LeadParameters leadParameters) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); UriBuilder url = new UriBuilder(servicesConfig.Lead + LeadServiceOperation.GetLeads()); url.Query = QueryStringHelper.ConvertToQueryString(leadParameters); var response = await client.GetAsync(url.ToString()); if (response.IsSuccessStatusCode) { var leads = JsonConvert.DeserializeObject <List <LeadDataCollectionResponse> >(await response.Content.ReadAsStringAsync()); return(new APIResponse(leads, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetLeads()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Creates the follow lead. /// </summary> /// <param name="leadId">The lead identifier.</param> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> CreateFollowLead(int leadId, CreateLeadValidationRequest request) { try { string filename = ""; var folderName = Path.Combine("CallRecordings"); var pathToSave = Path.Combine("D:", "HappyWedding", folderName); if (request.CallRecordingFile != null) { if (request.CallRecordingFile.Length > 0) { string format = Path.GetExtension(request.CallRecordingFile.FileName); filename = leadId + "_CallRecord_" + DateTime.Now + format; string filenme = filename.Replace(":", "."); var filePath = Path.Combine(pathToSave, filenme); using var fileStream = new FileStream(filePath, FileMode.Create); request.CallRecordingFile.CopyTo(fileStream); } } request.CallRecordingFile = null; request.CallRecordings = filename; var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.Lead + LeadServiceOperation.CreateFollowLead(leadId), contentPost); //return JsonConvert.DeserializeObject<APIResponse>(await response.Content.ReadAsStringAsync()); if (response.IsSuccessStatusCode) { var leadValidation = JsonConvert.DeserializeObject <LeadValidationResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(leadValidation, HttpStatusCode.Created)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'CreateFollowLead()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Deletes the Multidetail. /// </summary> /// <param name="details">The details.</param> /// <returns></returns> public async Task <APIResponse> DeleteMultiDetails(MultidetailIdDetails details) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var response = await client.DeleteAsync(servicesConfig.Lead + LeadServiceOperation.DeleteMultiDetails(details.MultidetailId)); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'DeleteMultiDetails()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Deletes the lead quote. /// </summary> /// <param name="quoteId">The quote identifier.</param> /// <returns></returns> public async Task <APIResponse> DeleteLeadQuote(int quoteId) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var response = await client.DeleteAsync(servicesConfig.Lead + LeadServiceOperation.DeleteLeadQuote(quoteId)); //return JsonConvert.DeserializeObject<APIResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'DeleteLeadQuote()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Updates the Multidetail. /// </summary> /// <param name="details">The details.</param> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> UpdateMultiDetails(MultidetailIdDetails details, UpdateMultidetailLeadRequest request) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PutAsync(servicesConfig.Lead + LeadServiceOperation.UpdateMultiDetails(details.MultidetailId), contentPost); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'UpdateMultiDetails()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Gets the Multidetail. /// </summary> /// <param name="details">The details.</param> /// <returns></returns> public async Task <APIResponse> GetMultiDetailsByCode(string Code) { try { var client = httpClientFactory.CreateClient(LeadServiceOperation.serviceName); var response = await client.GetAsync(servicesConfig.Lead + LeadServiceOperation.GetMultiDetailsById(Code)); if (response.IsSuccessStatusCode) { var multidetail = JsonConvert.DeserializeObject <List <MultidetailResponse> >(await response.Content.ReadAsStringAsync()); return(new APIResponse(multidetail, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetMultiDetailsById()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }