Пример #1
0
        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));
        }
Пример #2
0
        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();
        }
Пример #3
0
        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);
        }