public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,DateOfBirth,MainCategory")] Author author) { if (ModelState.IsValid) { author.Id = Guid.NewGuid(); _context.Add(author); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(author)); }
public void UpdateCourse(Course course) { var actualCourse = _context.Courses.Where(x => x.CourseId == course.CourseId).FirstOrDefault(); actualCourse.Description = course.Description; actualCourse.Title = course.Title; actualCourse.AuthorId = course.AuthorId; _context.Add(actualCourse); _context.SaveChanges(); }
public void AddCourse(Guid authorId, Course course) { if (authorId == Guid.Empty) { throw new ArgumentNullException(nameof(authorId)); } if (course == null) { throw new ArgumentNullException(nameof(course)); } course.AuthorId = authorId; _Context.Add(course); }