public async Task Update(UpdateCourseInput input) { var isExistCourse = await _courseRepository.GetAll().AnyAsync(x => x.Id == input.Id); if (!isExistCourse) { throw new UserFriendlyException(L("DontExistCourse")); } var course = await _courseRepository.GetAll().FirstAsync(x => x.Id == input.Id); course.CategoryId = input.CourseCategoryId; course.Description = input.CourseDescription; course.Title = input.CourseTitle; course.Price = input.CoursePrice; course.Quota = input.CourseQuato; course.StartDate = input.CourseStartDate; course.EndDate = input.CourseEndDate; await _courseRepository.UpdateAsync(course); }
public async Task <UpdateCoursePayload> UpdateCourseAsync( UpdateCourseInput input, [ScopedService] DatabaseContext context, CancellationToken cancellationToken) { var course = await context.Courses.FindAsync(new object[] { input.CourseId }, cancellationToken); if (course is null) { return(new UpdateCoursePayload( new [] { new UserError("Course not found.", CourseErrorCodes.COURSE_NOT_FOUND) })); } course.Name = input.Name; course.Description = input.Description; await context.SaveChangesAsync(cancellationToken); return(new UpdateCoursePayload(course)); }
public void UpdateCourse(UpdateCourseInput input) { var course = ObjectMapper.Map <Course>(input); _courseManager.UpdateStudent(course); }