Exemplo n.º 1
0
 public async Task<IActionResult> GetUsers([FromBody]SearchRequestVM searchRequestVM)
 {
     try
     {                
         #region Error Checking                
         GenericResponseVM genericResponse = null;                
         if (searchRequestVM.Client == null && string.IsNullOrWhiteSpace(searchRequestVM.Client.Url))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
         }
         #endregion
         searchRequestVM.SearchObject.SearchTerm = (!string.IsNullOrWhiteSpace(searchRequestVM.SearchObject.SearchTerm)) ? 
             searchRequestVM.SearchObject.SearchTerm : string.Empty;
         IList<Users> users = await userRepositoy.GetUsersAsync(searchRequestVM);
         if (users != null && users.Count != 0)
         {
             return matterCenterServiceFunctions.ServiceResponse(users, (int)HttpStatusCode.OK);
         }
         else
         {
             Users noResult = new Users()
             {
                 Name = errorSettings.PeoplePickerNoResults,
                 LogOnName = string.Empty,
                 Email = string.Empty,
                 EntityType = string.Empty
             };
             users.Add(noResult);
             return matterCenterServiceFunctions.ServiceResponse(users, (int)HttpStatusCode.OK);
         }
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates matter
        /// </summary>        
        /// <param name="client">Client object containing Client data</param>
        /// <param name="details">Term Store object containing Term store data</param>
        /// <returns>Returns JSON object to the client</returns>        ///
        public IActionResult Update([FromBody]MatterInformationVM matterInformation)
        {            
            string editMatterValidation = string.Empty;            
            var matter = matterInformation.Matter;
            var client = matterInformation.Client;
            var userid = matterInformation.UserIds;
            try
            {
                spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"];
                #region Error Checking                
                ErrorResponse errorResponse = null;                
                if (matterInformation.Client == null && matterInformation.Matter == null && matterInformation.MatterDetails == null)
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message = errorSettings.MessageNoInputs,
                        ErrorCode = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Validations
                GenericResponseVM validationResponse = validationFunctions.IsMatterValid(matterInformation, int.Parse(ServiceConstants.EditMatterPermission), null); 
                if(validationResponse != null)
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message = validationResponse.Value,
                        ErrorCode = validationResponse.Code,                        
                    };
                    return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                }

                if (null != matter.Conflict && !string.IsNullOrWhiteSpace(matter.Conflict.Identified))
                {
                    if (matter.AssignUserNames.Count==0)
                    {                        
                        errorResponse = new ErrorResponse()
                        {
                            Message = errorSettings.IncorrectInputUserNamesMessage,
                            ErrorCode = errorSettings.IncorrectInputUserNamesCode,                            
                        };
                        return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                    }
                    else
                    {
                        if (Convert.ToBoolean(matter.Conflict.Identified, CultureInfo.InvariantCulture))
                        {
                            validationResponse = editFunctions.CheckSecurityGroupInTeamMembers(client, matter, userid);
                            if (validationResponse != null)
                            {
                                errorResponse = new ErrorResponse()
                                {
                                    Message = validationResponse.Value,
                                    ErrorCode = validationResponse.Code,
                                };
                                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                            }
                        }
                    }
                }
                else
                {                    
                    errorResponse = new ErrorResponse()
                    {
                        Message = errorSettings.IncorrectInputConflictIdentifiedMessage,
                        ErrorCode = errorSettings.IncorrectInputConflictIdentifiedCode,
                    };
                    return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Upadte Matter
                GenericResponseVM genericResponse = matterProvision.UpdateMatter(matterInformation);
                if(genericResponse==null)
                {
                    var result = new GenericResponseVM()
                    {
                        Code = "200",
                        Value= "Update Success"
                    };
                    return matterCenterServiceFunctions.ServiceResponse(result, (int)HttpStatusCode.OK);
                }
                else
                {
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.NotModified);
                }

                #endregion
                
            }
            catch (Exception ex)
            {
                MatterRevertList matterRevertListObject = new MatterRevertList()
                {
                    MatterLibrary = matterInformation.Matter.Name,
                    MatterOneNoteLibrary = matterInformation.Matter.Name + matterSettings.OneNoteLibrarySuffix,
                    MatterCalendar = matterInformation.Matter.Name + matterSettings.CalendarNameSuffix,
                    MatterTask = matterInformation.Matter.Name + matterSettings.TaskNameSuffix,
                    MatterSitePages = matterSettings.MatterLandingPageRepositoryName
                };
                //editFunctions.RevertMatterUpdates(client, matter, matterRevertListObject, loggedInUserName, userPermissionOnLibrary, listItemId, isEditMode);
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);                
                throw;
            }
            finally
            {

            }
        }
Exemplo n.º 3
0
 private GenericResponseVM GenericResponse(string code, string value)
 {
     GenericResponseVM genericResponseVM = new GenericResponseVM();
     genericResponseVM.Code = errorSettings.IncorrectInputUserRolesCode;
     genericResponseVM.Value = errorSettings.IncorrectInputUserRolesMessage;
     return genericResponseVM;
 }
Exemplo n.º 4
0
        public GenericResponseVM UploadFiles(IFormFile uploadedFile, string fileExtension, string originalName, 
            string folderName, string fileName, string clientUrl, string folder, string documentLibraryName)
        {
            GenericResponseVM genericResponse = null;
            try
            {                
                Dictionary<string, string> mailProperties = ContinueUpload(uploadedFile, fileExtension);
                //setting original name property for attachment
                if (string.IsNullOrWhiteSpace(mailProperties[ServiceConstants.MailOriginalName]))
                {
                    mailProperties[ServiceConstants.MAIL_ORIGINAL_NAME] = originalName;
                }

                genericResponse = docRepository.UploadDocument(folderName, uploadedFile, fileName, mailProperties, clientUrl, folder, documentLibraryName);
            }
            catch(Exception ex)
            {
                genericResponse = new GenericResponseVM()
                {
                    Code = UploadEnums.UploadFailure.ToString(),
                    Value = folderName,
                    IsError = true
                };
            }
            return genericResponse;

        }        
Exemplo n.º 5
0
        public IActionResult AssignUserPermissions([FromBody] MatterMetdataVM matterMetadataVM)
        {
            var client = matterMetadataVM.Client;
            var matter = matterMetadataVM.Matter;
            try
            {
                
                var matterConfigurations = matterMetadataVM.MatterConfigurations;
                GenericResponseVM genericResponse = null;
                if (null == client && null == matter && null == client.Url && null == matterConfigurations)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }

                var genericResponseVM = matterProvision.AssignUserPermissions(matterMetadataVM);
                if (genericResponseVM != null && genericResponseVM.IsError == true)
                {
                    genericResponseVM.IsError = true;
                    return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.BadRequest);
                }
                var assignPermissions = new
                {
                    ReturnValue = true
                };
                return matterCenterServiceFunctions.ServiceResponse(assignPermissions, (int)HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                matterProvision.DeleteMatter(matterMetadataVM as MatterVM);
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 6
0
        public IActionResult AssignContentType([FromBody] MatterMetadata matterMetadata)
        {

            GenericResponseVM genericResponse = null;
            if (null == matterMetadata && null == matterMetadata.Client && null == matterMetadata.Matter && 
                matterMetadata.ManagedColumnTerms==null)
            {
                genericResponse = new GenericResponseVM()
                {
                    Value = errorSettings.MessageNoInputs,
                    Code = HttpStatusCode.BadRequest.ToString(),
                    Description = $"No input data is passed to assigncontenttype for the {errorSettings.Item}",
                    IsError = true
                };
                
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);               
            }

            // For each value in the list of Content Type Names
            // Add that content Type to the Library
            Matter matter = matterMetadata.Matter;
            Client client = matterMetadata.Client;            

            var matterInformationVM = new MatterInformationVM()
            {
                Client = client,
                Matter = matter,
            };
            try
            {                
                genericResponse = validationFunctions.IsMatterValid(matterInformationVM, int.Parse(ServiceConstants.ProvisionMatterAssignContentType, 
                    CultureInfo.InvariantCulture), null);
                if (genericResponse != null)
                { 
                    matterProvision.DeleteMatter(matterInformationVM as MatterVM);
                    genericResponse.Description = $"Error occurred when asigning content type to the {errorSettings.Item}";

                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                genericResponse = matterProvision.AssignContentType(matterMetadata);
                if (genericResponse != null && genericResponse.IsError==true)
                {
                    matterProvision.DeleteMatter(matterInformationVM as MatterVM);
                    genericResponse.Description = $"Error occurred when asigning content type to the {errorSettings.Item}";

                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
            }
            catch (Exception exception)
            {
                ///// SharePoint Specific Exception
                matterProvision.DeleteMatter(matterInformationVM as MatterVM);
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(exception);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
                
            }
        }
Exemplo n.º 7
0
        public IActionResult Update([FromBody]MatterInformationVM matterInformation)
        {
            string editMatterValidation = string.Empty;
            var matter = matterInformation.Matter;
            var client = matterInformation.Client;
            var userid = matterInformation.UserIds;
            try
            {

                #region Error Checking                
                GenericResponseVM genericResponse = null;
                if (matterInformation.Client == null && matterInformation.Matter == null && matterInformation.MatterDetails == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Description = $"No input data is passed to update the {errorSettings.Item}",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Validations
                GenericResponseVM validationResponse = validationFunctions.IsMatterValid(matterInformation, int.Parse(ServiceConstants.EditMatterPermission), null);
                if (validationResponse != null)
                {
                    validationResponse.IsError = true;
                    return matterCenterServiceFunctions.ServiceResponse(validationResponse, (int)HttpStatusCode.BadRequest);
                }

                if (null != matter.Conflict && !string.IsNullOrWhiteSpace(matter.Conflict.Identified))
                {
                    if (matter.AssignUserNames.Count == 0)
                    {
                        genericResponse = new GenericResponseVM()
                        {
                            Value = errorSettings.IncorrectInputUserNamesMessage,
                            Code = errorSettings.IncorrectInputUserNamesCode,
                            IsError = true
                        };
                        return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                    }
                    else
                    {
                        if (Convert.ToBoolean(matter.Conflict.Identified, CultureInfo.InvariantCulture))
                        {
                            validationResponse = editFunctions.CheckSecurityGroupInTeamMembers(client, matter, userid);
                            if (validationResponse != null)
                            {
                                validationResponse.IsError = true;
                                return matterCenterServiceFunctions.ServiceResponse(validationResponse, (int)HttpStatusCode.BadRequest);
                            }
                        }
                    }
                }
                else
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.IncorrectInputConflictIdentifiedMessage,
                        Code = errorSettings.IncorrectInputConflictIdentifiedCode,
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Upadte Matter
                genericResponse = matterProvision.UpdateMatter(matterInformation);
                if (genericResponse == null)
                {
                    var result = new GenericResponseVM()
                    {
                        Code = "200",
                        Value = "Update Success"
                    };
                    return matterCenterServiceFunctions.ServiceResponse(result, (int)HttpStatusCode.OK);
                }
                else
                {
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.NotModified);
                }

                #endregion

                

            }
            catch (Exception ex)
            {                
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
            }
            
        }
Exemplo n.º 8
0
        public IActionResult CheckMatterExists([FromBody]MatterMetdataVM matterMetadataVM)
        {
            
            GenericResponseVM genericResponse = ServiceUtility.GenericResponse(matterSettings.DeleteMatterCode, ServiceConstants.TRUE);
            var client = matterMetadataVM.Client;
            var matter = matterMetadataVM.Matter;
            var matterConfiguration = matterMetadataVM.MatterConfigurations;         
            if (null == client && null == matter && string.IsNullOrWhiteSpace(client.Url))
            {
                genericResponse = new GenericResponseVM()
                {
                    Value = errorSettings.MessageNoInputs,
                    Code = HttpStatusCode.BadRequest.ToString(),
                    Description = "No input data is passed",
                    IsError = true
                };
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
            }
            var matterInformation = new MatterInformationVM()
            {
                Client = client,
                Matter = matter
            };
            genericResponse = validationFunctions.IsMatterValid(matterInformation, int.Parse(ServiceConstants.PROVISION_MATTER_CHECK_MATTER_EXISTS, 
                CultureInfo.InvariantCulture), null);
            if(genericResponse!=null)
            {

                genericResponse.Description = "Validation failed";
                genericResponse.IsError = true;               
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
            }
                
            try
            {
               
                if (!matterMetadataVM.HasErrorOccurred)
                {
                    genericResponse = matterProvision.CheckMatterExists(matterMetadataVM);
                    if (genericResponse != null)
                    {                        
                        genericResponse.Description = genericResponse.Value;
                        genericResponse.IsError = true;
                        return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                    }
                    else
                    {
                        genericResponse = ServiceUtility.GenericResponse(ServiceConstants.SUCCESS, ServiceConstants.TRUE);
                        return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                    }
                }
                else
                {
                    genericResponse = matterProvision.DeleteMatter(matterMetadataVM as MatterVM);
                    genericResponse.IsError = true;
                    genericResponse.Description = $"Error occured when checking whether the given {errorSettings.Item} exisits or not";
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
            }
            catch (Exception exception)
            {
                genericResponse = matterProvision.DeleteMatter(matterMetadataVM as MatterVM);
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errResponse = customLogger.GenerateErrorResponse(exception);
                return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
            }                
        }
Exemplo n.º 9
0
        public IActionResult UpdateMetadata([FromBody]MatterMetdataVM matterMetdata)
        {
            string editMatterValidation = string.Empty;
            var matter = matterMetdata.Matter;
            var client = matterMetdata.Client;

            try
            {
                #region Error Checking                
                GenericResponseVM genericResponse = null;
                if (matterMetdata.Client == null && matterMetdata.Matter == null &&
                    matterMetdata.MatterDetails == null && matterMetdata.MatterProvisionFlags == null && 
                    matterMetdata.MatterDetails.ManagedColumnTerms==null)
                {
                    matterProvision.DeleteMatter(matterMetdata as MatterVM);
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Validations
                MatterInformationVM matterInfo = new MatterInformationVM()
                {
                    Client = matterMetdata.Client,
                    Matter = matterMetdata.Matter,
                    MatterDetails = matterMetdata.MatterDetails
                };
                genericResponse = validationFunctions.IsMatterValid(matterInfo,
                    int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList),
                    matterMetdata.MatterConfigurations);
                if (genericResponse != null)
                {
                    matterProvision.DeleteMatter(matterMetdata as MatterVM);
                    genericResponse.Description = $"Error occurred while updating the {errorSettings.Item} metadata.";
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion   

                try
                {                   

                    genericResponse = matterProvision.UpdateMatterMetadata(matterMetdata);
                    if (genericResponse == null)
                    {
                        genericResponse = new GenericResponseVM()
                        {
                            Code = "200",
                            Value = "Update Success"
                        };
                        
                    }
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                catch (Exception ex)
                {
                    matterProvision.DeleteMatter(matterMetdata as MatterVM);
                    customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                    var errResponse = customLogger.GenerateErrorResponse(ex);
                    return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                matterProvision.DeleteMatter(matterMetdata as MatterVM);
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
            }

        }
Exemplo n.º 10
0
        public async Task<IActionResult> GetPermissionLevels([FromBody]Client client)
        {
            try
            {                
                #region Error Checking                
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                #endregion
                IList<Role> roles = null;

                ServiceUtility.RedisCacheHostName = generalSettings.RedisCacheHostName;
                string result = ServiceUtility.GetDataFromAzureRedisCache(ServiceConstants.CACHE_PERMISSIONS);
                if (string.IsNullOrEmpty(result))
                {
                    roles = await userRepositoy.GetPermissionLevelsAsync(client);
                    ServiceUtility.SetDataIntoAzureRedisCache<IList<Role>>(ServiceConstants.CACHE_PERMISSIONS, roles);
                }
                else
                {
                    roles = JsonConvert.DeserializeObject<IList<Role>>(result);
                }                
                return matterCenterServiceFunctions.ServiceResponse(roles, (int)HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
Exemplo n.º 11
0
        public IActionResult IsLoginUserOwner([FromBody]Client client)
        {
            try
            {

                #region Error Checking                
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Value = errorSettings.MessageNoInputs,
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                #endregion
                bool isLoginUserOwner = userRepositoy.IsLoginUserOwner(client);
                var loginUserPartOfOwnerGroup = new
                {
                    IsLoginUserOwner = isLoginUserOwner
                };
                return matterCenterServiceFunctions.ServiceResponse(loginUserPartOfOwnerGroup, (int)HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
Exemplo n.º 12
0
        public IActionResult UserProfilePicture([FromBody]Client client)
        {
            try
            {
                #region Error Checking                
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                #endregion
                var userInfo = userRepositoy.GetUserProfilePicture(client);
                return matterCenterServiceFunctions.ServiceResponse(userInfo, (int)HttpStatusCode.OK);
            }
            catch(Exception ex)
            {
                return matterCenterServiceFunctions.ServiceResponse("Error in getting user profile picture", (int)HttpStatusCode.OK);
            }
            
        }
Exemplo n.º 13
0
        public IActionResult DownloadAttachmentsAsStream([FromBody]MailAttachmentDetails mailAttachmentDetails)
        {
            try
            {
                
                #region Error Checking                
                GenericResponseVM genericResponse = null;
                if (mailAttachmentDetails == null && mailAttachmentDetails.FullUrl == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                #endregion 
                Stream downloadAttachments = documentProvision.DownloadAttachments(mailAttachmentDetails);

                var fileContentResponse = new HttpResponseMessage(HttpStatusCode.OK);
                fileContentResponse.Headers.Clear();

                fileContentResponse.Content = new StreamContent(downloadAttachments);

                fileContentResponse.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(DocumentProvision.ReturnExtension(string.Empty));
                //fileContentResponse.Headers.Add("Content-Type", ReturnExtension(string.Empty));
                fileContentResponse.Content.Headers.Add("Content-Length", downloadAttachments.Length.ToString());
                fileContentResponse.Content.Headers.Add("Content-Description", "File Transfer");

                //application/octet-stream
                fileContentResponse.Content.Headers.Add("Content-Disposition", "attachment; filename=" + documentSettings.TempEmailName + new Guid().ToString() + ServiceConstants.EMAIL_FILE_EXTENSION);
                fileContentResponse.Content.Headers.Add("Content-Transfer-Encoding", "binary");
                fileContentResponse.Content.Headers.Expires = DateTimeOffset.Now.AddDays(-1); ;
                fileContentResponse.Headers.Add("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
                fileContentResponse.Headers.Add("Pragma", "public");
                var fileAttachmentContent = fileContentResponse.Content.ReadAsStringAsync();
                var response = new
                {
                    fileAttachment = fileAttachmentContent,
                    fileName = documentSettings.TempEmailName + Guid.NewGuid().ToString() + ServiceConstants.EMAIL_FILE_EXTENSION
                };
                return new ObjectResult(response);
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }        
Exemplo n.º 14
0
        /// <summary>
        /// Updates matter metadata - Stamps properties to the created matter.
        /// </summary>        
        /// <param name="client">Client object containing Client data</param>
        /// <param name="details">Term Store object containing Term store data</param>
        /// <returns>Returns JSON object to the client</returns>        ///
        public IActionResult UpdateMetadata([FromBody]MatterMetdataVM matterMetdata)
        {
            string editMatterValidation = string.Empty;
            var matter = matterMetdata.Matter;
            var client = matterMetdata.Client;
            
            try
            {
                spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"];
                #region Error Checking                
                ErrorResponse errorResponse = null;
                if (matterMetdata.Client == null && matterMetdata.Matter == null && 
                    matterMetdata.MatterDetails == null && matterMetdata.MatterProvisionFlags==null)
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message = errorSettings.MessageNoInputs,
                        ErrorCode = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion

                #region Validations
                MatterInformationVM matterInfo = new MatterInformationVM()
                {
                    Client = matterMetdata.Client,
                    Matter = matterMetdata.Matter,
                    MatterDetails = matterMetdata.MatterDetails
                };
                GenericResponseVM genericResponse = validationFunctions.IsMatterValid(matterInfo, 
                    int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList), 
                    matterMetdata.MatterConfigurations);
                if (genericResponse != null)
                {
                    matterProvision.DeleteMatter(client, matter);
                    errorResponse = new ErrorResponse()
                    {
                        Message = genericResponse.Value,
                        ErrorCode = genericResponse.Code,
                    };
                    return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion   
                try
                {
                    genericResponse = matterProvision.UpdateMatterMetadata(matterMetdata);
                    if (genericResponse == null)
                    {
                        var result = new GenericResponseVM()
                        {
                            Code = "200",
                            Value = "Update Success"
                        };
                        return matterCenterServiceFunctions.ServiceResponse(result, (int)HttpStatusCode.OK);
                    }
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.NotModified);
                }
                catch(Exception ex)
                {
                    matterProvision.DeleteMatter(client, matter);
                    customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                    throw;
                }
            }
            catch (Exception ex)
            {                
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
            
        }
Exemplo n.º 15
0
 public IActionResult SaveConfigurations([FromBody]MatterConfigurations matterConfigurations)
 {
     try
     {
         #region Error Checking                
         GenericResponseVM genericResponse = null;
         if (matterConfigurations==null &&  string.IsNullOrWhiteSpace(matterConfigurations.ClientUrl))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 Description = "No input data is passed",
                 IsError = true
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
         }
         #endregion
         GenericResponseVM genericResponseVM = matterProvision.SaveConfigurations(matterConfigurations);
         return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errorResponse = customLogger.GenerateErrorResponse(ex);
         return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK);
     }
 }
Exemplo n.º 16
0
        public IActionResult ShareMatter([FromBody] MatterInformationVM matterInformation)
        {
            var client = matterInformation.Client;            
            try
            {


                GenericResponseVM genericResponse = null;
                if (matterInformation == null && matterInformation.Client==null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }

                var genericResponseVM = matterProvision.ShareMatterToExternalUser(matterInformation);
                if (genericResponseVM != null && genericResponseVM.IsError == true)
                {
                    genericResponseVM.IsError = true;
                    genericResponseVM.Description = $"Error occurred when sharing {errorSettings.Item} to the External user";
                    return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.BadRequest);
                }
                var assignPermissions = new
                {
                    ReturnValue = true
                };
                return matterCenterServiceFunctions.ServiceResponse(assignPermissions, (int)HttpStatusCode.OK);
            }
            catch (Exception ex)
            {                
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 17
0
        public IActionResult CanCreateMatter([FromBody]Client client)
        {
            GenericResponseVM genericResponse = null;
            if (null == client && null != client.Url)
            {
                genericResponse = new GenericResponseVM()
                {
                    Value = errorSettings.MessageNoInputs,
                    Code = HttpStatusCode.BadRequest.ToString(),
                    Description = "No input data is passed",
                    IsError = true
                };
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
            }
            try
            {
                var canCreateMatter = matterRepositoy.CanCreateMatter(client);

                var canLoginUserCreateMatter = new
                {
                    CanCreateMatter = true
                };

                return matterCenterServiceFunctions.ServiceResponse(canLoginUserCreateMatter, (int)HttpStatusCode.OK);
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(exception);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 18
0
 public IActionResult OneNoteUrlExists([FromBody]MatterInformationVM matterInformation)
 {
     GenericResponseVM genericResponse = null;
     try
     {
         if (matterInformation == null && matterInformation.Client == null && string.IsNullOrWhiteSpace(matterInformation.RequestedUrl))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
         }
         bool oneNoteUrlExists = matterRepositoy.OneNoteUrlExists(matterInformation);
         var oneNoteExists = new
         {
             OneNoteUrlExists = oneNoteUrlExists
         };
         return matterCenterServiceFunctions.ServiceResponse(oneNoteExists, (int)HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errResponse = customLogger.GenerateErrorResponse(ex);
         return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
     }            
 }
Exemplo n.º 19
0
        public IActionResult CheckSecurityGroupExists([FromBody]MatterInformationVM matterInformationVM)
        {
            
            GenericResponseVM genericResponse = null;
            var client = matterInformationVM.Client;
            var matter = matterInformationVM.Matter;            
            
            if (null == client && null == matter && null != client.Url)
            {
                genericResponse = new GenericResponseVM()
                {
                    Value = errorSettings.MessageNoInputs,
                    Code = HttpStatusCode.BadRequest.ToString(),
                    Description = "No input data is passed",
                    IsError = true
                };
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
            }            

            try
            {
                if (0 == matter.AssignUserEmails.Count)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.IncorrectInputUserNamesMessage,
                        Code = errorSettings.IncorrectInputUserNamesCode,
                        Description = "No input data is passed",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }

                genericResponse = matterProvision.CheckSecurityGroupExists(matterInformationVM);
                if(genericResponse != null)
                {
                   // genericResponse.Description = "No input data is passed";
                    genericResponse.IsError = true;
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
                }
                genericResponse = ServiceUtility.GenericResponse(ServiceConstants.SUCCESS, ServiceConstants.TRUE);
                return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errResponse = customLogger.GenerateErrorResponse(exception);
                return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 20
0
 public async Task<IActionResult> GetMatterCounts([FromBody]SearchRequestVM searchRequestVM)
 {
     try
     {
         //Get the authorization token from the Request header                
         GenericResponseVM genericResponse = null;
         #region Error Checking                
         if (searchRequestVM == null && searchRequestVM.Client == null && searchRequestVM.SearchObject == null)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 Description = $"No input data is passed to fetch  {errorSettings.Item}s count",
                 IsError = true
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
         }
         #endregion                
         int allMatterCounts = await matterProvision.GetAllCounts(searchRequestVM);
         int myMatterCounts = await matterProvision.GetMyCounts(searchRequestVM);
         int pinnedMatterCounts = await matterProvision.GetPinnedCounts(searchRequestVM);
         var matterCounts = new
         {
             AllMatterCounts = allMatterCounts,
             MyMatterCounts = myMatterCounts,
             PinnedMatterCounts = pinnedMatterCounts,
         };
         return matterCenterServiceFunctions.ServiceResponse(matterCounts, (int)HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errorResponse = customLogger.GenerateErrorResponse(ex);
         return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
     }
 }
Exemplo n.º 21
0
 public IActionResult Create([FromBody] MatterMetdataVM matterMetdataVM)
 {
     
     GenericResponseVM genericResponseVM = null;            
     if (null == matterMetdataVM && null == matterMetdataVM.Client && null == matterMetdataVM.Matter && string.IsNullOrWhiteSpace(matterMetdataVM.Client.Url))
     {
         genericResponseVM = new GenericResponseVM()
         {
             Value = errorSettings.MessageNoInputs,
             Code = HttpStatusCode.BadRequest.ToString(),
             Description = $"No input data is passed to create the {errorSettings.Item}",
             IsError = true
         };
         return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.BadRequest);
     }
     try
     {
         genericResponseVM = matterProvision.CreateMatter(matterMetdataVM);
         if (genericResponseVM != null && genericResponseVM.IsError == true)
         {
             //Matter not created successfully
             genericResponseVM.IsError = true;
             genericResponseVM.Description = "Matter page not created successfully";
             
             return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.OK);
         }
         //Matter page created successfully
         genericResponseVM = new GenericResponseVM
         {
             Code = HttpStatusCode.OK.ToString(),
             Value = "Matter page created successfully"
         };
         return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.OK);
     }
     catch (Exception exception)
     {
         matterProvision.DeleteMatter(matterMetdataVM as MatterVM);
         customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errResponse = customLogger.GenerateErrorResponse(exception);
         return matterCenterServiceFunctions.ServiceResponse(errResponse, (int)HttpStatusCode.InternalServerError);
     }
 }
Exemplo n.º 22
0
        public async Task<IActionResult> UnPin([FromBody]PinRequestMatterVM pinRequestMatterVM)
        {
            try
            {

                #region Error Checking                
                GenericResponseVM genericResponse = null;                
                if (pinRequestMatterVM == null && pinRequestMatterVM.Client == null && pinRequestMatterVM.MatterData == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Description = $"No input data is passed to fetch the unpinned  {errorSettings.Item}",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion
                var isMatterUnPinned = await matterRepositoy.UnPinRecordAsync<PinRequestMatterVM>(pinRequestMatterVM);
                var matterUnPinned = new
                {
                    IsMatterUnPinned = isMatterUnPinned
                };
                return matterCenterServiceFunctions.ServiceResponse(matterUnPinned, (int)HttpStatusCode.OK);

            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 23
0
 public async Task<IActionResult> GetPin([FromBody]SearchRequestVM searchRequestVM)
 {
     try
     {                
         #region Error Checking                
         GenericResponseVM genericResponse = null;
         
         if (searchRequestVM == null)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 IsError = true,
                 Description = $"No input data is passed to fetch the pinned {errorSettings.Item}"
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
         }
         #endregion
         var pinResponseVM = await matterRepositoy.GetPinnedRecordsAsync(searchRequestVM);                
         return matterCenterServiceFunctions.ServiceResponse(pinResponseVM.MatterDataList, (int)HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errorResponse = customLogger.GenerateErrorResponse(ex);
         return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK);
     }
 }
Exemplo n.º 24
0
        public async Task<IActionResult> GetFolderHierachy([FromBody]MatterData matterData)
        {
            try
            {

                #region Error Checking                
                GenericResponseVM genericResponse = null;                
                if (matterData == null && string.IsNullOrWhiteSpace(matterData.MatterUrl) && string.IsNullOrWhiteSpace(matterData.MatterName))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed to get folder hierarchy",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion
                var folderHierarchy = await matterRepositoy.GetFolderHierarchyAsync(matterData);
                var response = new {
                    foldersList = folderHierarchy
                };
                return matterCenterServiceFunctions.ServiceResponse(response, (int)HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 25
0
        public GenericResponseVM CheckDuplicateDocument(string clientUrl, string folderName, string documentLibraryName, 
            string fileName, ContentCheckDetails contentCheck, bool allowContentCheck)
        {
            GenericResponseVM genericResponse = null;
            DuplicateDocument duplicateDocument = uploadHelperFunctions.DocumentExists(clientUrl, contentCheck, documentLibraryName, folderName, false);
            if (duplicateDocument != null && duplicateDocument.DocumentExists)
            {
                string documentPath = string.Concat(generalSettings.SiteURL, folderName, ServiceConstants.FORWARD_SLASH, fileName);
                string duplicateMessage = (allowContentCheck && duplicateDocument.HasPotentialDuplicate) ? errorSettings.FilePotentialDuplicateMessage : errorSettings.FileAlreadyExistMessage;
                duplicateMessage = $"{duplicateMessage}|{duplicateDocument.HasPotentialDuplicate}";
                genericResponse = new GenericResponseVM()
                {
                    IsError = true,
                    Code = UploadEnums.DuplicateDocument.ToString(),
                    Value = string.Format(CultureInfo.InvariantCulture, duplicateMessage, fileName, documentPath)
                };

            }
            return genericResponse;
        }
Exemplo n.º 26
0
        public IActionResult GetStampedProperties([FromBody]MatterVM matterVM)
        {
            try
            {


                #region Error Checking                
                GenericResponseVM genericResponse = null;
                if (matterVM == null && matterVM.Client == null && matterVM.Matter != null && string.IsNullOrWhiteSpace(matterVM.Matter.Name))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value = errorSettings.MessageNoInputs,
                        Code = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed to get stamped properties",
                        IsError = true
                    };
                    return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.BadRequest);
                }
                #endregion
                //ToDo: Need to concert this method to async
                var matterStampedProperties = matterProvision.GetStampedProperties(matterVM);
                //ToDo: Need to do nulk check on  matterStampedProperties
                return matterCenterServiceFunctions.ServiceResponse(matterStampedProperties, (int)HttpStatusCode.OK);
            }

            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Function to validate client information
 /// </summary>
 /// <param name="client">Client object</param>
 /// <param name="methodNumber">Number indicating which method needs to be validated</param>
 /// <returns>String that contains error message</returns>
 internal GenericResponseVM ValidateClientInformation(Client client, int methodNumber)
 {
     GenericResponseVM response = new GenericResponseVM();
     if (string.IsNullOrWhiteSpace(client.Url))
     {
         response.Code = errorSettings.IncorrectInputClientUrlCode;
         response.Value = errorSettings.IncorrectInputClientUrlMessage;                
     }
     else if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber || 
         int.Parse(ServiceConstants.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber || 
         int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList, CultureInfo.InvariantCulture) == methodNumber)
     {
         if (string.IsNullOrWhiteSpace(client.Id))
         {
             
             response.Code = errorSettings.IncorrectInputClientIdCode;
             response.Value = errorSettings.IncorrectInputClientIdMessage;
         }
         else if (string.IsNullOrWhiteSpace(client.Name))
         {                   
             response.Code = errorSettings.IncorrectInputClientNameCode;
             response.Value = errorSettings.IncorrectInputClientNameMessage;
         }
     }
     return response;
 }
Exemplo n.º 28
0
 public async Task<IActionResult> GetConfigurations([FromBody]string siteCollectionPath)
 {
     try
     {
         #region Error Checking                
         GenericResponseVM genericResponse = null;
         if (string.IsNullOrWhiteSpace(siteCollectionPath))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value = errorSettings.MessageNoInputs,
                 Code = HttpStatusCode.BadRequest.ToString(),
                 Description = "No input data is passed",
                 IsError = true
             };
             return matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK);
         }
         #endregion
         GenericResponseVM genericResponseVM = await matterRepositoy.GetConfigurationsAsync(siteCollectionPath);
         return matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         var errorResponse = customLogger.GenerateErrorResponse(ex);
         return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK);
     }
 }
Exemplo n.º 29
0
 public GenericResponseVM IsMatterValid(MatterInformationVM matterInformation, int methodNumber, MatterConfigurations matterConfigurations)
 {
     GenericResponseVM genericResponse = null;
     var matterDetails = matterInformation.MatterDetails;
     if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) <= methodNumber && 
         int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) >= methodNumber && 
         !spList.CheckPermissionOnList(matterSettings.ProvisionMatterAppURL, matterSettings.SendMailListName, PermissionKind.EditListItems))
     {
         genericResponse = new GenericResponseVM();
         //return string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.IncorrectInputUserAccessMessage);
         genericResponse.Code = errorSettings.IncorrectInputUserAccessCode;
         genericResponse.Value = errorSettings.IncorrectInputUserAccessMessage;
     }
     else
     {
         
         if (matterInformation.Client!=null)
         {
             genericResponse = new GenericResponseVM();
             genericResponse = ValidateClientInformation(matterInformation.Client, methodNumber);
             if (genericResponse!=null)
             {
                 return genericResponse;
             }
         }
         if (matterInformation.Matter!=null)
         {
             genericResponse = MatterMetadataValidation(matterInformation.Matter, matterInformation.Client, 
                 methodNumber, matterConfigurations);
             if (genericResponse!=null)
             {
                 return genericResponse;
             }
             if (int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber)
             {
                 genericResponse = RoleCheck(matterInformation.Matter);
                 if (genericResponse!=null)
                 {
                     return genericResponse;
                 }
             }
             if (matterInformation.Matter.Permissions!=null)
             {
                 bool isFullControlPresent = ValidateFullControlPermission(matterInformation.Matter);
                 if (!isFullControlPresent)
                 {                            
                     return GenericResponse(errorSettings.IncorrectInputUserAccessCode, errorSettings.ErrorEditMatterMandatoryPermission);
                 }
             }
         }
         if (null != matterDetails && !(int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber))
         {
             if (string.IsNullOrWhiteSpace(matterDetails.PracticeGroup))
             {                        
                 return GenericResponse(errorSettings.IncorrectInputPracticeGroupCode, errorSettings.IncorrectInputPracticeGroupMessage);
             }
             if (string.IsNullOrWhiteSpace(matterDetails.AreaOfLaw))
             {
                 
                 return GenericResponse(errorSettings.IncorrectInputAreaOfLawCode, errorSettings.IncorrectInputAreaOfLawMessage);
             }
             if (string.IsNullOrWhiteSpace(matterDetails.SubareaOfLaw))
             {                        
                 return GenericResponse(errorSettings.IncorrectInputSubareaOfLawCode, errorSettings.IncorrectInputSubareaOfLawMessage);
             }
             try
             {
                 if (string.IsNullOrWhiteSpace(matterDetails.ResponsibleAttorney))
                 {                            
                     return GenericResponse(errorSettings.IncorrectInputResponsibleAttorneyCode, errorSettings.IncorrectInputResponsibleAttorneyMessage);
                 }
                 else
                 {
                     IList<string> userNames = matterDetails.ResponsibleAttorney.Split(';').ToList<string>();
                     matterRespository.ResolveUserNames(matterInformation.Client, userNames).FirstOrDefault();
                 }
             }
             catch (Exception)
             {                        
                 return GenericResponse(errorSettings.IncorrectInputResponsibleAttorneyCode, errorSettings.IncorrectInputResponsibleAttorneyMessage);
             }
         }
     }
     return genericResponse;
 }
Exemplo n.º 30
0
        public GenericResponseVM GetConfigurations(string siteCollectionUrl, string listName)
        {
            try
            {
                GenericResponseVM genericResponse = null;
                ListItem settingsItem = null;
                using (ClientContext clientContext = spoAuthorization.GetClientContext(siteCollectionUrl))
                {
                    if (spList.CheckPermissionOnList(clientContext, listName, PermissionKind.EditListItems))
                    {
                        string listQuery = string.Format(CultureInfo.InvariantCulture, camlQueries.MatterConfigurationsListQuery,
                            searchSettings.ManagedPropertyTitle, searchSettings.MatterConfigurationTitleValue);
                        settingsItem = spList.GetData(clientContext, listNames.MatterConfigurationsList, listQuery).FirstOrDefault();
                        if (settingsItem != null)
                        {
                            genericResponse = new GenericResponseVM();
                            genericResponse.Code = WebUtility.HtmlDecode(Convert.ToString(settingsItem[searchSettings.MatterConfigurationColumn]));
                            genericResponse.Value = Convert.ToString(settingsItem[searchSettings.ColumnNameModifiedDate], CultureInfo.InvariantCulture);
                            return genericResponse;
                        }
                        else
                        {
                            genericResponse = new GenericResponseVM();
                            genericResponse.Code = "0";
                            genericResponse.Value = string.Empty;
                            return genericResponse;
                        }
                    }
                    else
                    {
                        genericResponse = new GenericResponseVM();
                        genericResponse.Code = errorSettings.UserNotSiteOwnerCode;
                        genericResponse.Value = errorSettings.UserNotSiteOwnerMessage;
                        genericResponse.IsError = true;
                        return genericResponse;
                    }

                }

            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }