/// <summary> /// 编辑ForecastRecord /// </summary> protected virtual async Task Update(ForecastRecordEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _entityRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _entityRepository.UpdateAsync(entity); }
/// <summary> /// 新增ForecastRecord /// </summary> protected virtual async Task <ForecastRecordEditDto> Create(ForecastRecordEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 // var entity = ObjectMapper.Map <ForecastRecord>(input); var entity = input.MapTo <ForecastRecord>(); entity = await _entityRepository.InsertAsync(entity); return(entity.MapTo <ForecastRecordEditDto>()); }
/// <summary> /// 获取编辑 ForecastRecord /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetForecastRecordForEditOutput> GetForEdit(NullableIdDto <Guid> input) { var output = new GetForecastRecordForEditOutput(); ForecastRecordEditDto editDto; if (input.Id.HasValue) { var entity = await _entityRepository.GetAsync(input.Id.Value); editDto = entity.MapTo <ForecastRecordEditDto>(); //forecastRecordEditDto = ObjectMapper.Map<List<forecastRecordEditDto>>(entity); } else { editDto = new ForecastRecordEditDto(); } output.ForecastRecord = editDto; return(output); }