Пример #1
0
        // Add note
        public async Task <IActionResult> OnPostAddAsync()
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            if (Note.Title == null &&
                Note.Text == null &&
                Note.LinkToPic == null &&
                Note.Tags == null)
            {
                return(RedirectToPage("Index"));
            }

            //Set note create date
            Note.CreatedDate = DateTime.Now;

            if (Note.Tags != null)
            {
                //Removes spaces from string
                Note.Tags = Note.Tags.Replace(" ", String.Empty);
                //Removes all commas from the beginning and end of a string
                Note.Tags = Note.Tags.TrimStart(',').TrimEnd(',');
                //Removes all duplicate commas
                Note.Tags = Regex.Replace(Note.Tags, ",{2,}", ",");
            }

            _noteData.Add(Note);

            return(RedirectToPage("Index"));
        }
Пример #2
0
 public IActionResult OnPost()
 {
     noteData.Add(n1);
     TempData["Message"] = "Message Added!";
     return(RedirectToPage("./Index"));
 }