本文整理汇总了C#中Question.CreateQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# Question.CreateQuestion方法的具体用法?C# Question.CreateQuestion怎么用?C# Question.CreateQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question.CreateQuestion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertQuestion
public ActionResult InsertQuestion(string txtTitle, string ddType, string EditorAskQuestion)
{
string strTemp = "";
if (Session["User"] != null)
{
txtTitle = txtTitle.Replace("``", "<");
txtTitle = txtTitle.Replace("~~", "&#");
user = (Users)Session["User"];
double dblQuestionID = 0;
Question question = new Question();
SqlConnection LclConn = new SqlConnection();
SqlTransaction SetTransaction = null;
bool IsinTransaction = false;
if (LclConn.State != ConnectionState.Open)
{
question.SetConnection = question.OpenConnection(LclConn);
SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
IsinTransaction = true;
}
else
{
question.SetConnection = LclConn;
}
question.QuestionTitle = txtTitle;
question.QuestionTypeId = int.Parse(ddType);
question.OptionID = 1;
//CleanBeforeInsert(ref EditorAskQuestion, ref strTemp);
question.QuestionDetails = EditorAskQuestion;
question.AskedDateTime = DateTime.Now;
if (user.UserId == 1)
{
int[] myy = new int[38] { 16, 17, 18, 19, 23, 24, 25, 26, 32, 34, 35, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 51, 52, 54, 55, 56, 57, 58, 59, 63, 69, 70, 71, 72, 73, 82, 104, 106 };
Random ran = new Random();
int mynum = myy[ran.Next(0, myy.Length)];
question.AskedUser = mynum;
}
else
{
question.AskedUser = user.UserId;
}
bool result = question.CreateQuestion(ref dblQuestionID, SetTransaction);
if (IsinTransaction && result)
{
SetTransaction.Commit();
Mail mail = new Mail();
mail.Body = "<a>www.codeanalyze.com/Soln.aspx?QId=" + dblQuestionID.ToString() + "&QT=" + txtTitle + "</a>";
mail.FromAdd = "[email protected]";
mail.Subject = txtTitle;
mail.ToAdd = "[email protected]";
mail.IsBodyHtml = true;
if (user.Email != "[email protected]")
{
mail.SendMail();
}
}
else
{
SetTransaction.Rollback();
}
question.CloseConnection(LclConn);
string title = txtTitle;
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");
txtTitle = rgx.Replace(txtTitle, "");
string strAck = "Question posted successfully, we will email you when users post answers.<br /> View your posted question ";
if (Request.Url.ToString().Contains("localhost"))
strAck += "<a style=\"color:blue;text-decoration:underline\" href=\"/CodeAnalyzeMVC2015/Que/Ans/" + dblQuestionID.ToString() + "/" + txtTitle.ToString().Replace(" ", "-") + "\">here</a>";
else
strAck += "<a style=\"color:blue;text-decoration:underline\" href=\"http://codeanalyze.com/Que/Ans/" + dblQuestionID.ToString() + "/" + txtTitle.ToString().Replace(" ", "-") + "\">here</a>";
strAck += "<br />";
ViewBag.Ack = strAck;
}
ConnManager conn = new ConnManager();
List<QuestionType> items = conn.GetQuestionType();
QuestionType types = new QuestionType();
types.Types = items;
return View("../Que/Post", types);
}