Esempio n. 1
0
 internal (int?, HttpStatusCode) WriteRTVote(RTVoteModel rTVote)
 {
     try
     {
         string sql = @"INSERT INTO rtvotes(title, firstContent, secondContent, startDatetime, endDatetime, createDatetime) " +
                      "VALUES(@title, @firstContent, @secondContent,@startDatetime, @endDatetime, @createDatetime) " +
                      "RETURNING idx";
         using (var db = new MySqlHelper())
         {
             return(db.QuerySingle <int>(sql, new { title = rTVote.Title, firstContent = rTVote.FirstContent,
                                                    secondContent = rTVote.SecondContent, startDatetime = MysqlFormatHelper.ConvertDatetime(rTVote.StartDatetime),
                                                    endDatetime = MysqlFormatHelper.ConvertDatetime(rTVote.EndDatetime),
                                                    createDatetime = MysqlFormatHelper.ConvertDatetime(rTVote.CreateDatetime) }), HttpStatusCode.OK);
         }
     }
     catch
     {
         return(null, HttpStatusCode.InternalServerError);
     }
 }
Esempio n. 2
0
 internal (int?, HttpStatusCode) WriteSurvey(SurveyEntity survey)
 {
     try
     {
         DynamicParameters param = new DynamicParameters();
         string            sql   = "insert into surveys (title, creatorIdx, createDatetime, startDatetime, endDatetime)" +
                                   $"values (@title, @creatorIdx, @createDatetime, @startDatetime, @endDatetime); select LAST_INSERT_ID();";
         param.Add("@title", survey.Title);
         param.Add("@creatorIdx", survey.CreatorIdx);
         param.Add("@createDatetime", MysqlFormatHelper.ConvertDatetime(survey.CreateDatetime));
         param.Add("@startDatetime", MysqlFormatHelper.ConvertDatetime(survey.StartDatetime));
         param.Add("@endDatetime", MysqlFormatHelper.ConvertDatetime(survey.EndDatetime));
         using (var db = new MySqlHelper())
         {
             return(db.QuerySingle <int>(sql, param), HttpStatusCode.OK);
         }
     }
     catch
     {
         return(null, HttpStatusCode.InternalServerError);
     }
 }