public ResponseResult <string> addToDo([FromQuery] string token, string title, string content, string proirity) { claim = (JwtClaim)_accessor.HttpContext.Items["user"]; try { if (string.IsNullOrEmpty(proirity) || string.IsNullOrEmpty(title)) { return(ResponseResult <string> .Error("操作异常")); } SYS_TODOLIST area = new SYS_TODOLIST { ID = Guid.NewGuid().ToString(), TITLE = title, CONTENT = content, PRIORITY = int.Parse(proirity), CREATETIME = DateTime.Now, UID = claim.uid, PROGRESS = 0 }; var b = ToDoService.addToDo(area, connstr); if (b) { return(ResponseResult <string> .Success("操作成功", "操作成功")); } else { return(ResponseResult <string> .Success("操作失败", "操作失败")); } } catch (Exception ex) { return(ResponseResult <string> .Error("系统异常")); } }
public bool addToDo(SYS_TODOLIST todo, string connstr) { bool _user = false; string sql = $@"INSERT INTO `sys_todolist` ( `id`, `title`, `content`, `priority`, `endtime`, `progress`, `uid`, `createtime` ) VALUES ( '{todo.ID}', '{todo.TITLE}', '{todo.CONTENT}', '{todo.PRIORITY}', NULL, '{todo.PROGRESS}', '{todo.UID}', '{todo.CREATETIME}' );" ; using (IDbConnection conn = DataBaseConfig.GetSqlConnection(DBType.mysql, connstr)) { var obj = conn.Execute(sql); if (obj >= 1) { _user = true; } } return(_user); }
public bool CreateEntity(SYS_TODOLIST entity, string connectionString = null) { throw new NotImplementedException(); }