protected virtual async Task <CoursesEditDto> CreateCoursesAsync(CoursesEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 var entity = ObjectMapper.Map <Courses>(input); entity = await _coursesRepository.InsertAsync(entity); return(entity.MapTo <CoursesEditDto>()); }
protected virtual async Task UpdateCoursesAsync(CoursesEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _coursesRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _coursesRepository.UpdateAsync(entity); }
/// <summary> /// MPA版本才会用到的方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetCoursesForEditOutput> GetCoursesForEdit(NullableIdDto <int> input) { var output = new GetCoursesForEditOutput(); CoursesEditDto coursesEditDto; if (input.Id.HasValue) { var entity = await _coursesRepository.GetAsync(input.Id.Value); coursesEditDto = entity.MapTo <CoursesEditDto>(); //coursesEditDto = ObjectMapper.Map<List <coursesEditDto>>(entity); } else { coursesEditDto = new CoursesEditDto(); } output.Courses = coursesEditDto; return(output); }