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