Esempio n. 1
0
 public static Post Parse(MySqlDataReader reader)
 {
     Post result = null;
     if (reader.HasRows)
     {
         result = new Post(
             reader.GetInt32("idpost"),
             reader.GetDateTime("created"),
             reader.GetString("message"));
     }
     return result;
 }
Esempio n. 2
0
        public ActionResult Create(Post post)
        {
            if (!ModelState.IsValid)
            {
                return View("new", post);
            }
            post.Save();

            if (!IsJsonRequest)
                return RedirectToAction("index");
            else
                return Json(new { status = "success" });
        }
Esempio n. 3
0
        public int Save(Post instance)
        {
            string cmdText = @"
                insert into posts (idpost, created, message)
                values (@idpost, @created, @message)
                on duplicate key update
                    message=values(message)";

            ulong id;
            ExecuteNonQuery(
                cmdText,
                "SaidWhat.Primary",
                CommandType.Text,
                new MySqlParameter[] {
                    new MySqlParameter("@idpost", instance.IdPost),
                    new MySqlParameter("@created", instance.Created),
                    new MySqlParameter("@message", instance.Message)
                },
                out id);
            return (int)id;
        }
Esempio n. 4
0
 public ActionResult New()
 {
     var model = new Post();
     return View("new", model);
 }