示例#1
0
        public async Task <IActionResult> UpdateFollowLead(int leadValidationId, [FromBody] UpdateLeadValidationRequest request)
        {
            var updateFollowLeadCommand = new UpdateLeadValidationCommand(leadValidationId, request);
            var result = await mediator.Send(updateFollowLeadCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
        /// <summary>
        /// Updates the follow lead.
        /// </summary>
        /// <param name="leadValidationId">The lead validation identifier.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <APIResponse> UpdateFollowLead(int leadId, int leadValidationId, UpdateLeadValidationRequest 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.PutAsync(servicesConfig.Lead + LeadServiceOperation.UpdateFollowLead(leadId, leadValidationId), contentPost);

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'UpdateFollowLead()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateLeadValidationCommand"/> class.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="request">The request.</param>
 public UpdateLeadValidationCommand(int id, UpdateLeadValidationRequest request)
 {
     Id      = id;
     Request = request;
 }
        public async Task <IActionResult> UpdateFollowLead(int leadId, int leadValidationId, [FromBody] UpdateLeadValidationRequest request)
        {
            var result = await leadService.UpdateFollowLead(leadId, leadValidationId, request);

            return(StatusCode((int)result.Code, result.Value));
        }