private async Task <RequestResult <InspectionCardOutput> > CreateAsync(EditInspectionCardInput input) { RequestResult <InspectionCardOutput> rst = new RequestResult <InspectionCardOutput>(); try { var data = ObjectMapper.Map <InspectionCard>(input); data = await _inspectionCardRepository.InsertAsync(data).ConfigureAwait(false); rst.ResultData = ObjectMapper.Map <InspectionCardOutput>(data); rst.Flag = true; } catch { rst.Flag = false; } return(rst); }
private async Task <RequestResult <InspectionCardOutput> > UpdateAsync(EditInspectionCardInput input) { RequestResult <InspectionCardOutput> rst = new RequestResult <InspectionCardOutput>(); try { var data = await _inspectionCardRepository.FirstOrDefaultAsync(u => u.Id == input.Id).ConfigureAwait(false); input.CreationTime = data.CreationTime; input.CreatorUserId = data.CreatorUserId; ObjectMapper.Map(input, data); rst.Flag = true; rst.ResultData = ObjectMapper.Map <InspectionCardOutput>(data);; } catch { rst.Flag = false; } return(rst); }
public async Task <RequestResult <InspectionCardOutput> > CreateOrUpdateAsync(EditInspectionCardInput input) { if (input == null) { return(null); } RequestResult <InspectionCardOutput> rst; LoginUserOutput CurrentUser = base.GetCurrentUser(); if (input.Id != null) { input.LastModificationTime = DateTime.Now; input.LastModifierUserId = CurrentUser.Id; rst = await this.UpdateAsync(input).ConfigureAwait(false); } else { input.CreationTime = DateTime.Now; input.CreatorUserId = CurrentUser.Id; rst = await this.CreateAsync(input).ConfigureAwait(false); } return(rst); }