public async Task <ApiResponse> GetStateUser(string userId) { var isNumeric = int.TryParse(userId, out int resualt); try { if (isNumeric) { var studentRepo = new StudentRepository(); var student = studentRepo.Select(studentCode: userId); var professorRepo = new ProfessorRepository(); var professor = professorRepo.Select(professorCode: userId); if (!(student is null)) { var studentState = studentRepo.GetStateForTickets(studentCode: userId); return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = studentState }); } if (!(professor is null)) { var professorState = new UserTicketState(); return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professorState }); } } return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), Result = null }); } catch (System.Exception ex) { throw; } }
public ActionResult <ApiResponse> Get(Helper.ObjectType objectType, string code, int randomNumber) { var smsRepository = new SmsRepository(); string mobile; switch (objectType) { case Helper.ObjectType.Student: var studentRepository = new StudentRepository(); mobile = studentRepository.Select(code).Mobile; return(new ApiResponse { ErrorId = mobile == null || mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = mobile == null || mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = $"{mobile}-{smsRepository.SendRandomNumber(mobile, randomNumber.ToString(), _config)}" }); case Helper.ObjectType.Professor: var professorRepository = new ProfessorRepository(); mobile = professorRepository.Select(code).Mobile; return(new ApiResponse { ErrorId = mobile == null || mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = mobile == null || mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = $"{mobile}-{smsRepository.SendRandomNumber(mobile, randomNumber.ToString(), _config)}" }); default: return(new ApiResponse()); } }
public async Task <ApiResponse> GetUser(string userId) { var isNumeric = int.TryParse(userId, out int resualt); if (isNumeric) { var studentRepo = new StudentRepository(); var student = studentRepo.Select(studentCode: userId); var professorRepo = new ProfessorRepository(); var professor = professorRepo.Select(professorCode: userId); if (!(student is null)) { return new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = student } } ; if (!(professor is null)) { return new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professor } } ; } return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), Result = null }); }
public ActionResult <ApiResponse> GetPicture(string code) { var studentRepo = new StudentRepository(); var studentPicture = studentRepo.Select(code, true)?.Picture; if (studentPicture != null) { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = studentPicture }); } var professorRepo = new ProfessorRepository(); var professorPicture = professorRepo.Select(code, true)?.Picture; if (professorPicture != null) { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professorPicture }); } return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), Result = "default" }); }
public ActionResult <ApiResponse> Get(string code) { var studentRepo = new StudentRepository(); var student = studentRepo.Select(code); if (student != null) { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = student.Active }); } var professorRepo = new ProfessorRepository(); var professor = professorRepo.Select(code); if (professor != null) { student.ObjectType = Helper.ObjectType.Professor; return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NoError, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professor.Active }); } return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), Result = "default" }); }
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" }); }
public ActionResult <ApiResponse> Get(Helper.ObjectType objectType, string code) { switch (objectType) { case Helper.ObjectType.Student: var studentRepo = new StudentRepository(); var student = studentRepo.Select(code); if (student.StudentCode != null) { var smsRepository = new SmsRepository(); var randomNumber = smsRepository.GetRandomNumber(student.Mobile); return(new ApiResponse { ErrorId = student.Mobile == null || student.Mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = student.Mobile == null || student.Mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = $"{student.Mobile}-{ smsRepository.SendRandomNumber(student.Mobile, randomNumber, _config)}" }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } case Helper.ObjectType.Professor: var professorRepository = new ProfessorRepository(); var professor = professorRepository.Select(code); if (professor.ProfessorCode != null) { var smsRepository = new SmsRepository(); var randomNumber = smsRepository.GetRandomNumber(professor.Mobile); return(new ApiResponse { ErrorId = professor.Mobile == null || professor.Mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = professor.Mobile == null || professor.Mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = $"{professor.Mobile}-{ smsRepository.SendRandomNumber(professor.Mobile, randomNumber, _config)}" }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } default: return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } }
public ActionResult <ApiResponse> Get(Helper.ObjectType objectType, string code, string password, string randomcode) { switch (objectType) { case Helper.ObjectType.Student: var studentRepo = new StudentRepository(); var student = studentRepo.Select(code); if (student.StudentCode != null) { var smsRepository = new SmsRepository(); var checkRandomnumberResult = smsRepository.CheckRandomNumber(student.Mobile, randomcode); //var studentNewPass = this.GetNewPassword(student.StudentCode ,""); var UrlChangePassForStudent_InBaseService = _config.BaseServiceUrlChangePasswordStudent + $"{student.StudentCode}/{password}"; var resualt1 = ClientHelper.GetValue <bool>(UrlChangePassForStudent_InBaseService, _config).FirstOrDefault(); if (checkRandomnumberResult) { return new ApiResponse { ErrorId = student.Mobile == null || student.Mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = student.Mobile == null || student.Mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = studentRepo.ChangePassword(student.StudentCode, password) && resualt1 } } ; else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.InCorrectRandomNumber, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.InCorrectRandomNumber).ToString(), }); } } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } case Helper.ObjectType.Professor: var professorRepository = new ProfessorRepository(); var professor = professorRepository.Select(code); if (professor.ProfessorCode != null) { var smsRepository = new SmsRepository(); var checkRandomnumberResult = smsRepository.CheckRandomNumber(professor.Mobile, randomcode); //var profNewPass = this.GetNewPassword("",professor.ProfessorCode); var UrlChangePassForTeacher_InBaseService = _config.BaseServiceUrlChangePasswordTeacher + $"{professor.ProfessorCode}/{password}"; var resualt2 = ClientHelper.GetValue <bool>(UrlChangePassForTeacher_InBaseService, _config).FirstOrDefault(); return(new ApiResponse { ErrorId = professor.Mobile == null || professor.Mobile.Trim() == "" ? (int)Helper.ApiOutputError.NotExists : (int)Helper.ApiOutputError.NoError, ErrorTitle = professor.Mobile == null || professor.Mobile.Trim() == "" ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString() : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(), Result = professorRepository.ChangePassword(professor.ProfessorCode, password) && resualt2 }); } else { return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } default: return(new ApiResponse { ErrorId = (int)Helper.ApiOutputError.NotExists, ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(), }); } }