private async Task <RequestResult <InspectionPlanTaskOutput> > CreateAsync(EditInspectionPlanTaskInput input) { RequestResult <InspectionPlanTaskOutput> rst = new RequestResult <InspectionPlanTaskOutput>(); try { var data = ObjectMapper.Map <InspectionPlanTask>(input); data = await _inspectionPlanTaskRepository.InsertAsync(data).ConfigureAwait(false); rst.ResultData = ObjectMapper.Map <InspectionPlanTaskOutput>(data); rst.Flag = true; } catch { rst.Flag = false; } return(rst); }
private async Task <RequestResult <InspectionPlanTaskOutput> > UpdateAsync(EditInspectionPlanTaskInput input) { RequestResult <InspectionPlanTaskOutput> rst = new RequestResult <InspectionPlanTaskOutput>(); try { var data = await _inspectionPlanTaskRepository.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 <InspectionPlanTaskOutput>(data);; } catch { rst.Flag = false; } return(rst); }
public async Task <RequestResult <InspectionPlanTaskOutput> > CreateOrUpdateAsync(EditInspectionPlanTaskInput input) { if (input == null) { return(new RequestResult <InspectionPlanTaskOutput>()); } RequestResult <InspectionPlanTaskOutput> 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); }