public ActionResult <ApiResponse> Get(string code, string password) { //studentCode and profCode are numeric string //employeeCode is string not numeric var trimedCode = code.Trim(); var trimedPass = password.Trim(); double inputCode; var isNum_Prof_Stu_Code = double.TryParse(trimedCode, out inputCode); if (isNum_Prof_Stu_Code) { var studentRepo = new StudentRepository(); var fsfStudent = studentRepo.Select(trimedCode); if (fsfStudent != null) { var checkPassword = studentRepo.CheckPassword(trimedCode, trimedPass); if (checkPassword) { fsfStudent.ObjectType = Helper.ObjectType.Student; return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = fsfStudent }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.InCorrectPassword, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.InCorrectPassword).ToString() }); } } else { var fNewStudent = studentRepo.Select(trimedCode, false, true); if (fNewStudent != null) { if (string.Compare(trimedPass, fNewStudent.NationalCode) == 0) { fNewStudent.ObjectType = Helper.ObjectType.Student; return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = fNewStudent }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.InCorrectPassword, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.InCorrectPassword).ToString() }); } } } //====================================================== var professorRepo = new ProfessorRepository(); var professor = professorRepo.Select(trimedCode); if (professor != null) { var checkPassword = professorRepo.CheckPassword(trimedCode, trimedPass); if (checkPassword) { professor.ObjectType = Helper.ObjectType.Professor; return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professor }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.InCorrectUserNameOrPassword, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.InCorrectPassword).ToString() }); } } } //############################################# var employeeRepository = new EmployeeRepository(); var employees = employeeRepository.Select(trimedCode); if (employees != null) { var checkPassword = employeeRepository.CheckPassword(trimedCode, trimedPass); if (checkPassword) { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = employees }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.InCorrectPassword, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.InCorrectPassword).ToString() }); } } //############################################# return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), Result = "default" }); }