public bool MapAnAssessmentToUser(int userId, int assessmentId) { bool isCreationSucess = true; try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[3]; paramArray[0] = RepositoryUtility.AddSQLParameter("@userid", SqlDbType.Int, ParameterDirection.Input, userId); paramArray[1] = RepositoryUtility.AddSQLParameter("@assessmentid", SqlDbType.Int, ParameterDirection.Input, assessmentId); paramArray[2] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.MapAnAssessmentToUser); string successMessage = Convert.ToString(paramArray[2].Value); if (successMessage.Equals("Success")) { isCreationSucess = true; } else { isCreationSucess = false; } } catch (Exception ex) { isCreationSucess = false; } return(isCreationSucess); }
public bool CreateRole(RoleData roleData) { bool isCreationSucess = true; try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[4]; paramArray[0] = RepositoryUtility.AddSQLParameter("@rolename", SqlDbType.VarChar, ParameterDirection.Input, roleData.RoleName); paramArray[1] = RepositoryUtility.AddSQLParameter("@roledescription", SqlDbType.VarChar, ParameterDirection.Input, roleData.RoleId); paramArray[2] = RepositoryUtility.AddSQLParameter("@CreatedBy", SqlDbType.VarChar, ParameterDirection.Input, roleData.CreatedBy); paramArray[3] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPCreateRole); string successMessage = Convert.ToString(paramArray[3].Value); if (successMessage.Equals("Success")) { isCreationSucess = true; } else { isCreationSucess = false; } } catch (Exception ex) { isCreationSucess = false; } return(isCreationSucess); }
public bool QuestionPaperUpload(Stream questionPaperStream, string description, string questionPaperName) { bool isInsertionSuccess = false; try { DataTable dtQuestionPaper = RepositoryUtility.ConvertCSVStreamToDatable(questionPaperStream); string xml = Convert.ToString(CreateQuestionPaperXMLFromDataTable(dtQuestionPaper)); IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[4]; paramArray[0] = RepositoryUtility.AddSQLParameter("@QuestionPaperName", SqlDbType.VarChar, ParameterDirection.Input, questionPaperName); paramArray[1] = RepositoryUtility.AddSQLParameter("@description", SqlDbType.VarChar, ParameterDirection.Input, description); paramArray[2] = RepositoryUtility.AddSQLParameter("@questionpaperxml", SqlDbType.Xml, ParameterDirection.Input, xml); paramArray[3] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPQuestionPaperUpload); string successMessage = Convert.ToString(paramArray[3].Value); if (successMessage.Equals("Success")) { isInsertionSuccess = true; } else { isInsertionSuccess = false; } } catch (Exception ex) { isInsertionSuccess = false; } return(isInsertionSuccess); }
public bool SaveAssessmentResultAndAnsweredSheet(AssessmentResultData assessmentResultData) { bool isSaveSucess = true; StringBuilder strBuilder = new StringBuilder(); XmlSerializer serializer = new XmlSerializer(typeof(List <QuestionPaperData>)); using (StringWriter textWriter = new StringWriter()) { serializer.Serialize(textWriter, assessmentResultData.AnsweredSheet); strBuilder.Append(textWriter.ToString()); } string answeredSheetINXML = Convert.ToString(strBuilder); try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[9]; paramArray[0] = RepositoryUtility.AddSQLParameter("@AssessmentId", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.AssessmentId); paramArray[1] = RepositoryUtility.AddSQLParameter("@userid ", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.UserId); paramArray[2] = RepositoryUtility.AddSQLParameter("@TotalQuestionsCount", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.TotalQuestionsCount); paramArray[3] = RepositoryUtility.AddSQLParameter("@RightAnsweredCount", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.RightAnsweredCount); paramArray[4] = RepositoryUtility.AddSQLParameter("@CanInsertAssessmentResult", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.CanInsertAssessmentResult?1:0); paramArray[5] = RepositoryUtility.AddSQLParameter("@questionPaperId", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.QuestionPaperId); paramArray[6] = RepositoryUtility.AddSQLParameter("@answeredSheet", SqlDbType.Xml, ParameterDirection.Input, answeredSheetINXML); paramArray[7] = RepositoryUtility.AddSQLParameter("@IsWriteLaterFlag", SqlDbType.Int, ParameterDirection.Input, assessmentResultData.IsWriteAssessmentLater?1:0); paramArray[8] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPSaveResultAndAnsweredSheet); string successMessage = Convert.ToString(paramArray[8].Value); if (successMessage.Equals("Success")) { isSaveSucess = true; } else { isSaveSucess = false; } } catch (Exception ex) { isSaveSucess = false; } return(isSaveSucess); }
public bool UpdateUser(UserData userData) { bool isUpdationSucess = true; try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[9]; paramArray[0] = RepositoryUtility.AddSQLParameter("@userid", SqlDbType.Int, ParameterDirection.Input, userData.UserId); paramArray[1] = RepositoryUtility.AddSQLParameter("@username", SqlDbType.VarChar, ParameterDirection.Input, userData.Username); paramArray[2] = RepositoryUtility.AddSQLParameter("@EmailAddress", SqlDbType.VarChar, ParameterDirection.Input, userData.EmailAddress); paramArray[3] = RepositoryUtility.AddSQLParameter("@FirstName", SqlDbType.VarChar, ParameterDirection.Input, userData.FirstName); paramArray[4] = RepositoryUtility.AddSQLParameter("@LastName", SqlDbType.VarChar, ParameterDirection.Input, userData.LastName); paramArray[5] = RepositoryUtility.AddSQLParameter("@ModifiedBy", SqlDbType.VarChar, ParameterDirection.Input, userData.ModifiedBy); paramArray[6] = RepositoryUtility.AddSQLParameter("@roleid", SqlDbType.Int, ParameterDirection.Input, (object)userData.Role.RoleId ?? DBNull.Value); paramArray[7] = RepositoryUtility.AddSQLParameter("@ProfilePicPath", SqlDbType.VarChar, ParameterDirection.Input, userData.ProfilePicPath); paramArray[8] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPUpdateUser); string successMessage = Convert.ToString(paramArray[8].Value); if (successMessage.Equals("Success")) { isUpdationSucess = true; } else { isUpdationSucess = false; } } catch (Exception ex) { isUpdationSucess = false; } return(isUpdationSucess); }
public bool CreateAssessment(AssessmentData assessmentData) { bool isCreationSucess = true; try { IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter[] paramArray = new SqlParameter[7]; paramArray[0] = RepositoryUtility.AddSQLParameter("@AssessmentName", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.AssessmentName); paramArray[1] = RepositoryUtility.AddSQLParameter("@AssessmentDescription", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.AssessmentDescription); paramArray[2] = RepositoryUtility.AddSQLParameter("@QuestionPaperId", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.QuestionPaperData.Id); paramArray[3] = RepositoryUtility.AddSQLParameter("@StartTime", SqlDbType.DateTime, ParameterDirection.Input, assessmentData.StartTime); paramArray[4] = RepositoryUtility.AddSQLParameter("@EndTime", SqlDbType.DateTime, ParameterDirection.Input, assessmentData.EndTime); paramArray[5] = RepositoryUtility.AddSQLParameter("@CreatedBy", SqlDbType.VarChar, ParameterDirection.Input, assessmentData.CreatedBy); paramArray[6] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPCreateAssessment); string successMessage = Convert.ToString(paramArray[6].Value); if (successMessage.Equals("Success")) { isCreationSucess = true; } else { isCreationSucess = false; } } catch (Exception ex) { isCreationSucess = false; } return(isCreationSucess); }
public bool MapModuleWisePageAccessWithRole(List <ModulewisePageAccessData> listModulewisePermissionData) { bool isCreationSucess = false; try { DataTable removePermissionTypeTable = new DataTable("ModuleRolePermisisonType"); //we create column names as per the type in DB removePermissionTypeTable.Columns.Add("ModuleId", typeof(Int32)); removePermissionTypeTable.Columns.Add("RoleId", typeof(Int32)); removePermissionTypeTable.Columns.Add("PermissionId", typeof(Int32)); DataTable AddPermissionTypeTable = new DataTable("ModuleRolePermisisonType"); //we create column names as per the type in DB AddPermissionTypeTable.Columns.Add("ModuleId", typeof(Int32)); AddPermissionTypeTable.Columns.Add("RoleId", typeof(Int32)); AddPermissionTypeTable.Columns.Add("PermissionId", typeof(Int32)); int roleid = -1; foreach (var modulewisePermissionData in listModulewisePermissionData) { if (modulewisePermissionData.Role != null) { if (modulewisePermissionData.Role.RoleId != 0) { roleid = modulewisePermissionData.Role.RoleId; } } foreach (var page in modulewisePermissionData.pageList) { if (page.IsPageSelected) { DataRow modulewisePageAccessRow = AddPermissionTypeTable.NewRow(); modulewisePageAccessRow[0] = modulewisePermissionData.Module.ModuleId; modulewisePageAccessRow[1] = roleid; modulewisePageAccessRow[2] = page.PageId; AddPermissionTypeTable.Rows.Add(modulewisePageAccessRow); } else { DataRow modulewisePageAccessRow = removePermissionTypeTable.NewRow(); modulewisePageAccessRow[0] = modulewisePermissionData.Module.ModuleId; modulewisePageAccessRow[1] = roleid; modulewisePageAccessRow[2] = page.PageId; removePermissionTypeTable.Rows.Add(modulewisePageAccessRow); } } } SqlParameter parameter = new SqlParameter(); //The parameter for the SP must be of SqlDbType.Structured parameter.ParameterName = "@RemoveModuleRolePagetype"; parameter.SqlDbType = System.Data.SqlDbType.Structured; parameter.Value = removePermissionTypeTable; IDatabaseHelper objSqlADOHelper = new SqlADOHelper(); SqlParameter parameter1 = new SqlParameter(); //The parameter for the SP must be of SqlDbType.Structured parameter1.ParameterName = "@MapModuleRolepagetype"; parameter1.SqlDbType = System.Data.SqlDbType.Structured; parameter1.Value = AddPermissionTypeTable; SqlParameter[] paramArray = new SqlParameter[3]; paramArray[0] = parameter; paramArray[1] = parameter1; paramArray[2] = RepositoryUtility.AddSQLParameter("@responsemessage", SqlDbType.VarChar, ParameterDirection.Output, null, 500); objSqlADOHelper.GetOutputParamValue(paramArray, StoredProcedureNameConstants.SPMapModuleWisePageWithRole); string successMessage = Convert.ToString(paramArray[2].Value); if (successMessage.Equals("Success")) { isCreationSucess = true; } else { isCreationSucess = false; } } catch (Exception ex) { isCreationSucess = false; } return(isCreationSucess); }