protected virtual async Task <BookInfoEditDto> CreateBookInfoAsync(BookInfoEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 var entity = ObjectMapper.Map <BookInfo>(input); entity = await _bookinfoRepository.InsertAsync(entity); return(entity.MapTo <BookInfoEditDto>()); }
protected virtual async Task UpdateBookInfoAsync(BookInfoEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _bookinfoRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _bookinfoRepository.UpdateAsync(entity); }
/// <summary> /// 导出BookInfo为excel表 /// </summary> /// <returns></returns> //public async Task<FileDto> GetBookInfosToExcel(){ //var users = await UserManager.Users.ToListAsync(); //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users); //await FillRoleNames(userListDtos); //return _userListExcelExporter.ExportToFile(userListDtos); //} /// <summary> /// MPA版本才会用到的方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetBookInfoForEditOutput> GetBookInfoForEdit(NullableIdDto <int> input) { var output = new GetBookInfoForEditOutput(); BookInfoEditDto bookinfoEditDto; if (input.Id.HasValue) { var entity = await _bookinfoRepository.GetAsync(input.Id.Value); bookinfoEditDto = entity.MapTo <BookInfoEditDto>(); //bookinfoEditDto = ObjectMapper.Map<List <bookinfoEditDto>>(entity); } else { bookinfoEditDto = new BookInfoEditDto(); } output.BookInfo = bookinfoEditDto; return(output); }