Пример #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FirstName,LastName,DateOfBirth,MainCategory")] Author author)
        {
            if (id != author.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(author);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorExists(author.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
        public void UpdateCourse(Guid id, Course course)
        {
            var existingCourse = _context.Courses.FirstOrDefault(x => x.Id == id);

            course.AuthorId = existingCourse.AuthorId;
            _context.Update(course);
            _context.SaveChanges();
        }