public static bool InsertQuestion(ExamDomainModel model) { using (SqlConnection con = new SqlConnection(AppConfig.ConnectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand("sp_insert_question", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", model.ID); cmd.Parameters.AddWithValue("@ques_text", model.QuestionText ?? ""); cmd.Parameters.AddWithValue("@ques_image_url", model.QuestionImageUrl ?? ""); cmd.Parameters.AddWithValue("@sub_category_id", model.SubCategoryId); cmd.Parameters.AddWithValue("@answer_img_urlA", model.AnswerImageUrlA ?? ""); cmd.Parameters.AddWithValue("@answer_img_urlB", model.AnswerImageUrlB ?? ""); cmd.Parameters.AddWithValue("@answer_img_urlC", model.AnswerImageUrlC ?? ""); cmd.Parameters.AddWithValue("@answer_img_urlD", model.AnswerImageUrlD ?? ""); cmd.Parameters.AddWithValue("@answer_img_urlE", model.AnswerImageUrlE ?? ""); cmd.Parameters.AddWithValue("@answer_textA", model.AnswerTextA ?? ""); cmd.Parameters.AddWithValue("@answer_textB", model.AnswerTextB ?? ""); cmd.Parameters.AddWithValue("@answer_textC", model.AnswerTextC ?? ""); cmd.Parameters.AddWithValue("@answer_textD", model.AnswerTextD ?? ""); cmd.Parameters.AddWithValue("@answer_textE", model.AnswerTextE ?? ""); cmd.Parameters.AddWithValue("@variant", model.Variants); cmd.Parameters.AddWithValue("@username", HttpContext.Current.User.Identity.Name.Contains("@") ? HttpContext.Current.User.Identity.Name : HttpContext.Current.User.Identity.Name + "@ady.az"); cmd.Parameters.AddWithValue("@lang_id", 2); cmd.Parameters.AddWithValue("@status", model.Status); cmd.Parameters.AddWithValue("@parent_category_id", model.ParentCategoryId); int affectedRows = cmd.ExecuteNonQuery(); return(affectedRows == 6); } } }
private ExamViewModel MaptoExamViewModel(ExamDomainModel domainModel) { return(new ExamViewModel() { ID = domainModel.ID, ParentCategoryId = domainModel.ParentCategoryId, SubCategoryId = domainModel.SubCategoryId, QuestionText = domainModel.QuestionText, Variants = domainModel.Variants, AnswerTextA = domainModel.AnswerTextA, AnswerTextB = domainModel.AnswerTextB, AnswerTextC = domainModel.AnswerTextC, AnswerTextD = domainModel.AnswerTextD, AnswerTextE = domainModel.AnswerTextE, Status = domainModel.Status, CreateDate = domainModel.CreateDate, Creator = domainModel.Creator }); }