예제 #1
0
        public static void Create(string uuid, string ip)
        {
            // IPエラー
            var ipCount = Convert.ToInt32(MySqlite.GetOne(
                                              "select count(1) from users " +
                                              "where ip = ? ",
                                              new object[] { ip }
                                              ));

            if (ipCount >= 1)
            {
                throw new Exception();
            }

            MySqlite.Execute(
                "insert into users " +
                "(uuid, ip, created_at) values " +
                "(?, ?, ?) ",
                new object[] { uuid, ip, Utility.GetDatetime() }
                );
            // 匿名ネームに変える
            int id = MySqlite.LastInsertedId();

            MySqlite.Execute(
                "update users " +
                "set name = ? " +
                "where id = ? ",
                new object[] { "匿名" + id.ToString(), id }
                );
        }
예제 #2
0
 public static bool Replace(int SubjectId, int UserId, int Point, string Comment)
 {
     return(MySqlite.Execute(
                "insert or replace into subject_votes " +
                "(user_id, subject_id, point, comment, updated_at) values " +
                "(?,?,?,?,?)",
                new object[] {
         UserId, SubjectId,
         Point, Comment, Utility.GetDatetime()
     }
                ) >= 1);
 }
예제 #3
0
        public static bool Create(int?userId, string title, string artist, string url, string comment)
        {
            if (IsExist(title, artist))
            {
                return(false);
            }

            return(MySqlite.Execute(
                       "insert into subjects " +
                       "(user_id, title, artist, url, comment, created_at) values " +
                       "(?, ?, ?, ?, ?, ?) ",
                       new object[] { userId, title, artist, url, comment, Utility.GetDatetime() }
                       ) >= 1);
        }