Microsoft.Legal.MatterCenter.ValidationFunctions.MatterDetailsValidation C# (CSharp) Method

MatterDetailsValidation() private method

Validates details of a matter and returns the validation status.
private MatterDetailsValidation ( Matter matter, Client client, int methodNumber, MatterConfigurations matterConfigurations ) : GenericResponseVM
matter Microsoft.Legal.MatterCenter.Models.Matter Matter object containing Matter data
client Microsoft.Legal.MatterCenter.Models.Client
methodNumber int Number indicating which method needs to be validated
matterConfigurations Microsoft.Legal.MatterCenter.Models.MatterConfigurations
return Microsoft.Legal.MatterCenter.Models.GenericResponseVM
        internal GenericResponseVM MatterDetailsValidation(Matter matter, Client client, int methodNumber, 
            MatterConfigurations matterConfigurations)
        {
            GenericResponseVM genericResponseVM = null;
            if (matterConfigurations.IsMatterDescriptionMandatory)
            {
                if (string.IsNullOrWhiteSpace(matter.Description))
                {             
                    return GenericResponse(errorSettings.IncorrectInputMatterDescriptionCode, errorSettings.IncorrectInputMatterDescriptionMessage);
                }
                else
                {
                    var matterDescription = Regex.Match(matter.Description, matterSettings.SpecialCharacterExpressionMatterDescription, RegexOptions.IgnoreCase);
                    if (int.Parse(matterSettings.MatterDescriptionLength, CultureInfo.InvariantCulture) < matter.Description.Length || !matterDescription.Success)
                    {  
                        return GenericResponse(errorSettings.IncorrectInputMatterDescriptionCode, errorSettings.IncorrectInputMatterDescriptionMessage);
                    }
                }
            }
            if (matterConfigurations.IsConflictCheck)
            {
                DateTime conflictCheckedOnDate;
                bool isValidDate = DateTime.TryParse(matter.Conflict.CheckOn, out conflictCheckedOnDate);
                if (!isValidDate || 0 > DateTime.Compare(DateTime.Now, conflictCheckedOnDate))
                {
                    return GenericResponse(errorSettings.IncorrectInputConflictDateCode, errorSettings.IncorrectInputConflictDateMessage);
                }
                if (string.IsNullOrWhiteSpace(matter.Conflict.Identified))
                {
                    return GenericResponse(errorSettings.IncorrectInputConflictIdentifiedCode, errorSettings.IncorrectInputConflictIdentifiedMessage);
                }
                else
                {
                    try
                    {
                        if (0 > string.Compare(ServiceConstants.FALSE, matter.Conflict.Identified, StringComparison.OrdinalIgnoreCase))
                        {
                            if (0 >= matter.BlockUserNames.Count())
                            {
                                return GenericResponse(errorSettings.IncorrectInputBlockUserNamesCode, errorSettings.IncorrectInputBlockUserNamesMessage);
                            }
                            else
                            {
                                //ToDo: Need to understand the need of this method
                                matterRespository.ResolveUserNames(client, matter.BlockUserNames).FirstOrDefault();
                            }
                        }
                    }
                    catch (Exception)
                    {              
                        return GenericResponse(errorSettings.IncorrectInputBlockUserNamesCode, errorSettings.IncorrectInputBlockUserNamesMessage);
                    }

                }
                if (string.IsNullOrWhiteSpace(matter.Conflict.CheckBy))
                {                                       
                    return GenericResponse(errorSettings.IncorrectInputConflictCheckByCode, errorSettings.IncorrectInputConflictCheckByMessage);
                }
                else
                {
                    try
                    {
                        //ToDo: Need to understand the need of this method                   
                        matterRespository.ResolveUserNames(client, new List<string>() { matter.Conflict.CheckBy }).FirstOrDefault();
                    }
                    catch (Exception)
                    {             
                        return GenericResponse(errorSettings.IncorrectInputConflictCheckByCode, errorSettings.IncorrectInputConflictCheckByMessage);
                    }
                }
            }
            if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber && 0 >= matter.Roles.Count())
            {        
                return GenericResponse(errorSettings.IncorrectInputUserRolesCode, errorSettings.IncorrectInputUserRolesMessage);
            }
            return genericResponseVM;
        }