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