Пример #1
0
        public async Task <IActionResult> AddNote(string title, string text, string isPrivate)
        {
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(text))
            {
                return(BadRequest("Title or text is empty"));
            }

            if (title.Length > MaxTitleLength || text.Length > MaxTextLength)
            {
                return(BadRequest("Title or text is too long"));
            }

            var user = await FindUserAsync(User?.Identity?.Name);

            var note = new Note
            {
                Author = user?.Name,
                Title  = title,
                Text   = text,
                Time   = DateTime.UtcNow
            };

            var gen = LuceneIndex.AddNote(user, note, isPrivate == "on");

            Response.Cookies.Append(IndexGenerationCookieName, gen.ToString());

            return(Ok("Ok"));
        }