Esempio n. 1
0
 public IActionResult UploadMail([FromBody] AttachmentRequestVM attachmentRequestVM)
 {
     try
     {
         var client         = attachmentRequestVM.Client;
         var serviceRequest = attachmentRequestVM.ServiceRequest;
         GenericResponseVM genericResponse = null;
         #region Error Checking
         //Input validation
         ErrorResponse errorResponse = null;
         if (client == null && serviceRequest == null && string.IsNullOrWhiteSpace(serviceRequest.MailId))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = errorSettings.MessageNoInputs,
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         #endregion
         //Upload email to the share point library
         genericResponse = documentProvision.UploadEmails(attachmentRequestVM);
         //If there is any error in uploading the email attachment, send that error information to the UI
         if (genericResponse != null && genericResponse.IsError == true)
         {
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         //If the email attachment is success, send the success response to the user
         genericResponse = new GenericResponseVM()
         {
             Code  = HttpStatusCode.OK.ToString(),
             Value = "Attachment upload success"
         };
         //Return the response with proper http status code and proper response object
         return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
 }