private async Task <RequestResult <InspectionResultOutput> > CreateAsync(EditInspectionResultInput input) { RequestResult <InspectionResultOutput> rst = new RequestResult <InspectionResultOutput>(); try { var data = ObjectMapper.Map <InspectionResult>(input); await _inspectionResultRepository.InsertOneAsync(data).ConfigureAwait(false); rst.ResultData = ObjectMapper.Map <InspectionResultOutput>(data); rst.Flag = true; } catch { rst.Flag = false; } return(rst); }
private async Task <RequestResult <InspectionResultOutput> > UpdateAsync(EditInspectionResultInput input) { RequestResult <InspectionResultOutput> rst = new RequestResult <InspectionResultOutput>(); try { var data = await _inspectionResultRepository.FirstOrDefaultAsync(e => e.Id == input.Id).ConfigureAwait(false); ObjectMapper.Map(input, data); await _inspectionResultRepository.UpdateOneAsync(data).ConfigureAwait(false); rst.Flag = true; rst.ResultData = ObjectMapper.Map <InspectionResultOutput>(data); } catch { rst.Flag = false; } return(rst); }
public async Task <RequestResult <InspectionResultOutput> > CreateOrUpdateAsync(EditInspectionResultInput input) { if (input == null) { return(null); } RequestResult <InspectionResultOutput> rst; if (input.Id != null) { rst = await this.UpdateAsync(input).ConfigureAwait(false); } else { rst = await this.CreateAsync(input).ConfigureAwait(false); } return(rst); }