예제 #1
0
        public IActionResult UpdateNotebook(string token, string notebookId, string title, string parentNotebookId, int seq, int usn)
        {
            User user = tokenSerivce.GetUserByToken(token);

            if (user == null)
            {
                ApiRe apiRe = new ApiRe()
                {
                    Ok  = false,
                    Msg = "NOTLOGIN",
                };

                return(Json(apiRe, MyJsonConvert.GetLeanoteOptions()));
            }
            else
            {
                Notebook notebook;
                if (notebookService.UpdateNotebookApi(user.UserId, notebookId.ToLongByHex(), title, parentNotebookId.ToLongByHex(), seq, usn, out notebook))
                {
                    ApiNotebook apiNotebook = fixNotebook(notebook);

                    return(Json(apiNotebook, MyJsonConvert.GetLeanoteOptions()));
                }
                else
                {
                    ApiRe apiRe = new ApiRe()
                    {
                        Ok  = false,
                        Msg = "UpdateNotebook is error",
                    };

                    return(Json(apiRe, MyJsonConvert.GetLeanoteOptions()));
                }
            }
        }
예제 #2
0
 public ApiNotebook[] fixNotebooks(Notebook[] notebooks)
 {
     ApiNotebook[] apiNotebooks = null;
     if (notebooks != null)
     {
         apiNotebooks = new ApiNotebook[notebooks.Length];
         for (int i = 0; i < notebooks.Length; i++)
         {
             apiNotebooks[i] = fixNotebook(notebooks[i]);
         }
     }
     return(apiNotebooks);
 }
예제 #3
0
        public IActionResult AddNotebook(string token, string title, string parentNotebookId, int seq)
        {
            User user = tokenSerivce.GetUserByToken(token);

            if (user == null)
            {
                ApiRe apiRe = new ApiRe()
                {
                    Ok  = false,
                    Msg = "NOTLOGIN",
                };

                return(Json(apiRe, MyJsonConvert.GetLeanoteOptions()));
            }
            else
            {
                Notebook notebook = new Notebook()
                {
                    NotebookId       = idGenerator.NextId(),
                    Title            = title,
                    Seq              = seq,
                    UserId           = user.UserId,
                    ParentNotebookId = parentNotebookId.ToLongByHex()
                };
                if (notebookService.AddNotebook(ref notebook))
                {
                    ApiNotebook apiNotebook = fixNotebook(notebook);

                    return(Json(apiNotebook, MyJsonConvert.GetLeanoteOptions()));
                }
                else
                {
                    ApiRe apiRe = new ApiRe()
                    {
                        Ok  = false,
                        Msg = "AddNotebook is error",
                    };

                    return(Json(apiRe, MyJsonConvert.GetLeanoteOptions()));
                }
            }
        }
예제 #4
0
        //添加notebook
        public IActionResult AddNotebook(string token, string title, string parentNotebookId, int seq)
        {
            User user = TokenSerivce.GetUserByToken(token);

            if (user == null)
            {
                ApiRe apiRe = new ApiRe()
                {
                    Ok  = false,
                    Msg = "Not logged in",
                };

                return(Json(apiRe, MyJsonConvert.GetOptions()));
            }
            else
            {
                Notebook notebook = new Notebook()
                {
                    NotebookId       = SnowFlake_Net.GenerateSnowFlakeID(),
                    Title            = title,
                    Seq              = seq,
                    UserId           = user.UserId,
                    ParentNotebookId = MyConvert.HexToLong(parentNotebookId)
                };
                if (NotebookService.AddNotebook(ref notebook))
                {
                    ApiNotebook apiNotebook = fixNotebook(notebook);

                    return(Json(apiNotebook, MyJsonConvert.GetOptions()));
                }
                else
                {
                    ApiRe apiRe = new ApiRe()
                    {
                        Ok  = false,
                        Msg = "AddNotebook is error",
                    };

                    return(Json(apiRe, MyJsonConvert.GetOptions()));
                }
            }
        }