private string GetRepresentativeType(Guid contractGuid, Guid currentUser, IEnumerable <QuestionaireUserAnswer> savedAnswers) { var userRole = _contractService.GetContractRoleByUserGuid(contractGuid, currentUser); var representativeType = string.Empty; if (userRole.Count() > 0) { var projectManager = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ProjectManager"); var projectManagerRole = userRole.FirstOrDefault(x => x.ToUpper() == projectManager); if (savedAnswers.Count() > 0) { var contractRepresentative = _configuration.GetSection("ContractRepresentatives").GetValue <string>("ContracRepresentative"); var accountingRepresentative = _configuration.GetSection("ContractRepresentatives").GetValue <string>("AccountRepresentative"); var contractRepresentativeRole = userRole.FirstOrDefault(x => x.ToUpper() == contractRepresentative); var accountingRepresentativeRole = userRole.FirstOrDefault(x => x.ToUpper() == accountingRepresentative); if (contractRepresentativeRole != null) { representativeType = contractRepresentative; } else { representativeType = "NotAccessable"; } if (accountingRepresentativeRole != null) { if (savedAnswers.Any(x => x.RepresentativeType == contractRepresentative)) { representativeType = accountingRepresentative; } if (savedAnswers.Any(x => x.RepresentativeType == accountingRepresentative)) { representativeType = string.Empty; } } } else { if (projectManagerRole != null) { representativeType = projectManager; } else { representativeType = "NotAccessable"; } } } return(representativeType); }