/// <summary> /// 编辑 /// </summary> public virtual async Task UpdateKonwledgeInfoAsync(KonwledgeInfoEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _KonwledgeInfoRepository.GetAsync(input.Id.Value); input.MapTo(entity); await _KonwledgeInfoRepository.UpdateAsync(entity); }
/// <summary> /// 新增 /// </summary> public virtual async Task <KonwledgeInfoEditDto> CreateKonwledgeInfoAsync(KonwledgeInfoEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 var entity = input.MapTo <KonwledgeInfo>(); entity = await _KonwledgeInfoRepository.InsertAsync(entity); return(entity.MapTo <KonwledgeInfoEditDto>()); }
public ActionResult Save(KonwledgeInfoEditDto dto) { try { KonwledgeInfoservice.CreateOrUpdateKonwledgeInfoAsync(new CreateOrUpdateKonwledgeInfoInput { KonwledgeInfoEditDto = dto }); return(RedirectToAction("/Index")); } catch { return(View()); } }
/// <summary> /// 通过Id获取信息进行编辑或修改 /// </summary> public GetKonwledgeInfoForEditOutput GetKonwledgeInfoForEdit(NullableIdDto <long> input) { var output = new GetKonwledgeInfoForEditOutput(); KonwledgeInfoEditDto KonwledgeInfoEditDto; if (input.Id.HasValue) { var entity = _KonwledgeInfoRepository.Get(input.Id.Value); KonwledgeInfoEditDto = entity.MapTo <KonwledgeInfoEditDto>(); } else { KonwledgeInfoEditDto = new KonwledgeInfoEditDto(); } output.KonwledgeInfo = KonwledgeInfoEditDto; return(output); }