Beispiel #1
0
        public async Task <IActionResult> Edit(string id, string NoteAvatar, [Bind("Id,Owner,OwnerId,Title,Content,Changed,Created,NoteAvatar")] Note note)
        {
            if (id != note.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string noteTitle = note.Title;
                    string avatar    = GetAvas(noteTitle);
                    note.NoteAvatar = avatar;
                    note.Changed    = DateTime.Now;
                    _context.Update(note);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteExists(note.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(note));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Owner,Title,Content,Created,Changed")] Note note)
        {
            if (id != note.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(note);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteExists(note.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(note));
        }