示例#1
0
        private AssessmentQuestionsModel ConvertAssessmentQuestionsViewModelToDomain(AssessmentQuestionsViewModel assessmentQuestionsViewModel)
        {
            AssessmentQuestionsModel assessmentQuestionsModel = new AssessmentQuestionsModel();

            assessmentQuestionsModel.QuestionId           = assessmentQuestionsViewModel.QuestionId;
            assessmentQuestionsModel.Question             = assessmentQuestionsViewModel.Question;
            assessmentQuestionsModel.QuestionImgFileName  = assessmentQuestionsViewModel.QuestionImgFileName;
            assessmentQuestionsModel.Option1Description   = assessmentQuestionsViewModel.Option1Description;
            assessmentQuestionsModel.Option1ImageFileName = assessmentQuestionsViewModel.Option1ImageFileName;
            assessmentQuestionsModel.IsOption1Correct     = assessmentQuestionsViewModel.IsOption1Correct;
            assessmentQuestionsModel.Option2Description   = assessmentQuestionsViewModel.Option2Description;
            assessmentQuestionsModel.Option2ImageFileName = assessmentQuestionsViewModel.Option2ImageFileName;
            assessmentQuestionsModel.IsOption2Correct     = assessmentQuestionsViewModel.IsOption2Correct;
            assessmentQuestionsModel.Option3Description   = assessmentQuestionsViewModel.Option3Description;
            assessmentQuestionsModel.Option3ImageFileName = assessmentQuestionsViewModel.Option3ImageFileName;
            assessmentQuestionsModel.IsOption3Correct     = assessmentQuestionsViewModel.IsOption3Correct;
            assessmentQuestionsModel.Option4Description   = assessmentQuestionsViewModel.Option4Description;
            assessmentQuestionsModel.IsOption4Correct     = assessmentQuestionsViewModel.IsOption4Correct;
            assessmentQuestionsModel.Option4ImageFileName = assessmentQuestionsViewModel.Option4ImageFileName;
            assessmentQuestionsModel.Option5Description   = assessmentQuestionsViewModel.Option5Description;
            assessmentQuestionsModel.Option5ImageFileName = assessmentQuestionsViewModel.Option5ImageFileName;
            assessmentQuestionsModel.IsOption5Correct     = assessmentQuestionsViewModel.IsOption5Correct;
            assessmentQuestionsModel.Option6Description   = assessmentQuestionsViewModel.Option6Description;
            assessmentQuestionsModel.Option6ImageFileName = assessmentQuestionsViewModel.Option6ImageFileName;
            assessmentQuestionsModel.IsOption6Correct     = assessmentQuestionsViewModel.IsOption6Correct;
            assessmentQuestionsModel.IsMultiChoiceAnswer  = assessmentQuestionsViewModel.IsMultiChoiceAnswer;
            assessmentQuestionsModel.IsActive             = true;
            assessmentQuestionsModel.CreatedOn            = DateTime.Now;
            assessmentQuestionsModel.LastEditedOn         = DateTime.Now;
            return(assessmentQuestionsModel);
        }
        public int SaveAssessmentQuestion(int assessmentPaperId, AssessmentQuestionsModel assessmentQuestionsModel)
        {
            int questionId = 0;

            if (assessmentQuestionsModel.QuestionId == 0)
            {
                questionId = 1;
            }
            return(questionId);
        }
 public int UpdateAssessmentQuestionDetails(AssessmentQuestionsModel assessmentQuestionsModel)
 {
     if (assessmentQuestionsModel.QuestionId == 1)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
 public int UpdateAssessmentQuestionDetails(AssessmentQuestionsModel assessmentQuestionsModel)
 {
     return(_IAssessmentRepository.UpdateAssessmentQuestionDetails(assessmentQuestionsModel));
 }
 public int SaveAssessmentQuestion(int assessmentPaperId, AssessmentQuestionsModel assessmentQuestionsModel)
 {
     return(_IAssessmentRepository.SaveAssessmentQuestion(assessmentPaperId, assessmentQuestionsModel));
 }
示例#6
0
        public ActionResult EditAssessmentQuestion(AssessmentViewModel assessmentViewModel)
        {
            int updateSuccess = 0;

            if (assessmentViewModel.AssessmentQuestions != null && assessmentViewModel.AssessmentQuestions.Count == 1)
            {
                if (assessmentViewModel.AssessmentQuestions[0].QuestionImg != null && assessmentViewModel.AssessmentQuestions[0].QuestionImg.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].QuestionImg.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentQuestionImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].QuestionImg.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].QuestionImgFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option1Image != null && assessmentViewModel.AssessmentQuestions[0].Option1Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option1Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option1Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option1ImageFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option2Image != null && assessmentViewModel.AssessmentQuestions[0].Option2Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option2Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option2Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option2ImageFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option3Image != null && assessmentViewModel.AssessmentQuestions[0].Option3Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option3Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option3Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option3ImageFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option4Image != null && assessmentViewModel.AssessmentQuestions[0].Option4Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option4Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option4Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option4ImageFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option5Image != null && assessmentViewModel.AssessmentQuestions[0].Option5Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option5Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option5Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option5ImageFileName = fileName;
                }

                if (assessmentViewModel.AssessmentQuestions[0].Option6Image != null && assessmentViewModel.AssessmentQuestions[0].Option6Image.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid() + "_" + Path.GetFileName(assessmentViewModel.AssessmentQuestions[0].Option6Image.FileName);
                    var path     = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[CommonConstants.AssessmentAnswerImgPath].ToString()), fileName);
                    assessmentViewModel.AssessmentQuestions[0].Option6Image.SaveAs(path);
                    assessmentViewModel.AssessmentQuestions[0].Option6ImageFileName = fileName;
                }


                AssessmentQuestionsModel assessmentQuestionsModel = ConvertAssessmentQuestionsViewModelToDomain(assessmentViewModel.AssessmentQuestions[0]);
                updateSuccess = _IAssessmentService.UpdateAssessmentQuestionDetails(assessmentQuestionsModel);
                if (updateSuccess > 0)
                {
                    return(RedirectToAction("ShowAssessmentPaperDetails", new { Id = CheckAccessAttribute.Encode(Convert.ToString(assessmentViewModel.AssessmentPaper.AssessmentPaperId)) }));
                }
                return(View("Error"));
            }
            return(View("Error"));
        }
        public AssessmentModel GetAssessmentPaperDetails(int assessmentPaperId)
        {
            AssessmentModel assessmentModel = new AssessmentModel();

            assessmentModel.AssessmentPaper        = new AssessmentPaperModel();
            assessmentModel.AssessmentPaperDetails = new List <AssessmentPaperDetailsModel>();
            assessmentModel.AssessmentQuestions    = new List <AssessmentQuestionsModel>();
            DataAccessClass dataAccessClass = new DataAccessClass();

            try
            {
                dataAccessClass.OpenConnection(DBConstants.GetDBConnectionString());
                SqlParameter[] sqlParam = new SqlParameter[1];
                sqlParam[0]       = new SqlParameter(SPParameter.AssessmentPaperId, SqlDbType.Int);
                sqlParam[0].Value = assessmentPaperId;
                SqlDataReader dr = dataAccessClass.ExecuteReaderSP(SPNames.GetAssessmentPaperDetailsById, sqlParam);
                while (dr.Read())
                {
                    assessmentModel.AssessmentPaper.AssessmentPaperId = Convert.ToInt32(dr[DbTableColumn.AssessmentPaperId]);
                    assessmentModel.AssessmentPaper.CourseId          = Convert.ToInt32(dr[DbTableColumn.CourseID]);
                    assessmentModel.AssessmentPaper.CourseName        = Convert.ToString(dr[DbTableColumn.CourseName]);
                    assessmentModel.AssessmentPaper.AssessmentDate    = Convert.ToDateTime(dr[DbTableColumn.AssessmentDate]);
                    assessmentModel.AssessmentPaper.TimeDuration      = Convert.ToInt32(dr[DbTableColumn.TimeDuration]);
                    assessmentModel.AssessmentPaper.TrainingNameId    = Convert.ToInt32(dr[DbTableColumn.TrainingNameID]);
                }
                if (dr.NextResult())
                {
                    while (dr.Read())
                    {
                        AssessmentPaperDetailsModel assessmentPaperDetailsModel = new AssessmentPaperDetailsModel();
                        assessmentPaperDetailsModel.AssessmentPaperDetailsId = Convert.ToInt32(dr[DbTableColumn.AssessmentPaperDetailsId]);
                        assessmentPaperDetailsModel.AssessmentPaperId        = Convert.ToInt32(dr[DbTableColumn.AssessmentPaperId]);
                        assessmentPaperDetailsModel.QuestionId    = Convert.ToInt32(dr[DbTableColumn.QuestionId]);
                        assessmentPaperDetailsModel.IsNewQuestion = Convert.ToBoolean(dr[DbTableColumn.IsNewQuestion]);
                        assessmentModel.AssessmentPaperDetails.Add(assessmentPaperDetailsModel);
                        AssessmentQuestionsModel assessmentQuestionsModel = new AssessmentQuestionsModel();
                        assessmentQuestionsModel.AssessmentPaperDetailsId = Convert.ToInt32(dr[DbTableColumn.AssessmentPaperDetailsId]);
                        assessmentQuestionsModel.AssessmentPaperId        = Convert.ToInt32(dr[DbTableColumn.AssessmentPaperId]);
                        assessmentQuestionsModel.QuestionId           = Convert.ToInt32(dr[DbTableColumn.QuestionId]);
                        assessmentQuestionsModel.Question             = Convert.ToString(dr[DbTableColumn.QuestionDescription]);
                        assessmentQuestionsModel.QuestionImgFileName  = Convert.ToString(dr[DbTableColumn.QuestionImgFileName]);
                        assessmentQuestionsModel.Option1Description   = Convert.ToString(dr[DbTableColumn.Option1Description]);
                        assessmentQuestionsModel.Option2Description   = Convert.ToString(dr[DbTableColumn.Option2Description]);
                        assessmentQuestionsModel.Option3Description   = Convert.ToString(dr[DbTableColumn.Option3Description]);
                        assessmentQuestionsModel.Option4Description   = Convert.ToString(dr[DbTableColumn.Option4Description]);
                        assessmentQuestionsModel.Option5Description   = Convert.ToString(dr[DbTableColumn.Option5Description]);
                        assessmentQuestionsModel.Option6Description   = Convert.ToString(dr[DbTableColumn.Option6Description]);
                        assessmentQuestionsModel.IsOption1Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption1Correct]);
                        assessmentQuestionsModel.IsOption2Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption2Correct]);
                        assessmentQuestionsModel.IsOption3Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption3Correct]);
                        assessmentQuestionsModel.IsOption4Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption4Correct]);
                        assessmentQuestionsModel.IsOption5Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption5Correct]);
                        assessmentQuestionsModel.IsOption6Correct     = Convert.ToBoolean(dr[DbTableColumn.IsOption6Correct]);
                        assessmentQuestionsModel.Option1ImageFileName = Convert.ToString(dr[DbTableColumn.Option1Image]);
                        assessmentQuestionsModel.Option2ImageFileName = Convert.ToString(dr[DbTableColumn.Option2Image]);
                        assessmentQuestionsModel.Option3ImageFileName = Convert.ToString(dr[DbTableColumn.Option3Image]);
                        assessmentQuestionsModel.Option4ImageFileName = Convert.ToString(dr[DbTableColumn.Option4Image]);
                        assessmentQuestionsModel.Option5ImageFileName = Convert.ToString(dr[DbTableColumn.Option5Image]);
                        assessmentQuestionsModel.Option6ImageFileName = Convert.ToString(dr[DbTableColumn.Option6Image]);
                        assessmentQuestionsModel.IsMultiChoiceAnswer  = Convert.ToBoolean(dr[DbTableColumn.IsMultiChoiceAnswer]);
                        assessmentModel.AssessmentQuestions.Add(assessmentQuestionsModel);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new RaveHRException(ex.Message, ex, Sources.DataAccessLayer, "GetAssessmentPaperDetails", "GetAssessmentPaperDetails", EventIDConstants.TRAINING_DATA_ACCESS_LAYER);
            }
            finally
            {
                dataAccessClass.CloseConncetion();
            }

            return(assessmentModel);
        }
        public int UpdateAssessmentQuestionDetails(AssessmentQuestionsModel assessmentQuestionsModel)
        {
            int           saveStatus    = 0;
            SqlConnection objConnection = null;
            SqlCommand    objCommand    = null;
            string        ConnStr       = string.Empty;

            try
            {
                ConnStr       = DBConstants.GetDBConnectionString();
                objConnection = new SqlConnection(ConnStr);
                objConnection.Open();

                Master master = new Master();

                objCommand             = new SqlCommand(SPNames.Assessment_UpdateQuestionDetails, objConnection);
                objCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter[] sqlParam = new SqlParameter[26];
                sqlParam[0]            = objCommand.Parameters.AddWithValue(SPParameter.QuestionId, assessmentQuestionsModel.QuestionId);
                sqlParam[1]            = objCommand.Parameters.AddWithValue(SPParameter.QuestionDescription, assessmentQuestionsModel.Question);
                sqlParam[2]            = objCommand.Parameters.AddWithValue(SPParameter.QuestionImage, assessmentQuestionsModel.QuestionImgFileName);
                sqlParam[3]            = objCommand.Parameters.AddWithValue(SPParameter.Option1Description, assessmentQuestionsModel.Option1Description);
                sqlParam[4]            = objCommand.Parameters.AddWithValue(SPParameter.Option1Image, assessmentQuestionsModel.Option1ImageFileName);
                sqlParam[5]            = objCommand.Parameters.AddWithValue(SPParameter.IsOption1Correct, assessmentQuestionsModel.IsOption1Correct);
                sqlParam[6]            = objCommand.Parameters.AddWithValue(SPParameter.Option2Description, assessmentQuestionsModel.Option2Description);
                sqlParam[7]            = objCommand.Parameters.AddWithValue(SPParameter.Option2Image, assessmentQuestionsModel.Option2ImageFileName);
                sqlParam[8]            = objCommand.Parameters.AddWithValue(SPParameter.IsOption2Correct, assessmentQuestionsModel.IsOption2Correct);
                sqlParam[9]            = objCommand.Parameters.AddWithValue(SPParameter.Option3Description, assessmentQuestionsModel.Option3Description);
                sqlParam[10]           = objCommand.Parameters.AddWithValue(SPParameter.Option3Image, assessmentQuestionsModel.Option3ImageFileName);
                sqlParam[11]           = objCommand.Parameters.AddWithValue(SPParameter.IsOption3Correct, assessmentQuestionsModel.IsOption3Correct);
                sqlParam[12]           = objCommand.Parameters.AddWithValue(SPParameter.Option4Description, assessmentQuestionsModel.Option4Description);
                sqlParam[13]           = objCommand.Parameters.AddWithValue(SPParameter.Option4Image, assessmentQuestionsModel.Option4ImageFileName);
                sqlParam[14]           = objCommand.Parameters.AddWithValue(SPParameter.IsOption4Correct, assessmentQuestionsModel.IsOption4Correct);
                sqlParam[15]           = objCommand.Parameters.AddWithValue(SPParameter.Option5Description, assessmentQuestionsModel.Option5Description);
                sqlParam[16]           = objCommand.Parameters.AddWithValue(SPParameter.Option5Image, assessmentQuestionsModel.Option5ImageFileName);
                sqlParam[17]           = objCommand.Parameters.AddWithValue(SPParameter.IsOption5Correct, assessmentQuestionsModel.IsOption5Correct);
                sqlParam[18]           = objCommand.Parameters.AddWithValue(SPParameter.Option6Description, assessmentQuestionsModel.Option6Description);
                sqlParam[19]           = objCommand.Parameters.AddWithValue(SPParameter.Option6Image, assessmentQuestionsModel.Option6ImageFileName);
                sqlParam[20]           = objCommand.Parameters.AddWithValue(SPParameter.IsOption6Correct, assessmentQuestionsModel.IsOption6Correct);
                sqlParam[21]           = objCommand.Parameters.AddWithValue(SPParameter.IsMultiChoiceAnswer, assessmentQuestionsModel.IsMultiChoiceAnswer);
                sqlParam[22]           = objCommand.Parameters.AddWithValue(SPParameter.LastModifiedById, master.GetEmployeeIDByEmailID());
                sqlParam[23]           = objCommand.Parameters.AddWithValue(SPParameter.LastModifiedDate, assessmentQuestionsModel.LastEditedOn);
                sqlParam[24]           = objCommand.Parameters.AddWithValue(SPParameter.IsActive, assessmentQuestionsModel.IsActive);
                sqlParam[25]           = objCommand.Parameters.AddWithValue(SPParameter.Status, 0);
                sqlParam[25].Direction = ParameterDirection.Output;
                objCommand.ExecuteNonQuery();
                saveStatus = Convert.ToInt32(sqlParam[25].Value);
            }
            catch (Exception ex)
            {
                throw new RaveHRException(ex.Message, ex, Sources.DataAccessLayer, "UpdateAssessmentQuestionDetails", "UpdateAssessmentQuestionDetails", EventIDConstants.TRAINING_DATA_ACCESS_LAYER);
            }
            finally
            {
                if (objConnection.State == ConnectionState.Open)
                {
                    objConnection.Close();
                }
            }
            return(saveStatus);
        }