Esempio n. 1
0
 public IActionResult UploadAttachments([FromBody] AttachmentRequestVM attachmentRequestVM)
 {
     try
     {
         var client         = attachmentRequestVM.Client;
         var serviceRequest = attachmentRequestVM.ServiceRequest;
         GenericResponseVM genericResponse = null;
         #region Error Checking
         ErrorResponse errorResponse = null;
         if (client == null && serviceRequest == null)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = errorSettings.MessageNoInputs,
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             //If the input validation is failed, send GenericResponseVM which contains the error information
             return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
         }
         #endregion
         if (serviceRequest.FolderPath.Count != serviceRequest.Attachments.Count)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = "Folder path count and attachment count are not same",
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             //If the input validation is failed, send GenericResponseVM which contains the error information
             return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
         }
         //Upload attachments to the sharepoint document library the user has choosen
         genericResponse = documentProvision.UploadAttachments(attachmentRequestVM);
         //If there is any error in uploading the attachment, send that error information to the UI
         if (genericResponse != null && genericResponse.IsError == true)
         {
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         //
         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;
     }
 }