public async Task <RequestResult <VideoDevOutput> > CreateOrUpdateAsync(EditVideoDevInput input) { if (input == null) { return(null); } if (_currentUser == null) { _currentUser = base.GetCurrentUser(); } return(input.Id != null ? await this.UpdateAsync(input).ConfigureAwait(false) : await this.CreateAsync(input).ConfigureAwait(false)); }
private async Task <RequestResult <VideoDevOutput> > CreateAsync(EditVideoDevInput input) { var rst = new RequestResult <VideoDevOutput>() { Flag = false }; try { input.CreationTime = DateTime.Now; input.CreatorUserId = _currentUser.Id; var data = ObjectMapper.Map <VideoDev>(input); data = await _repository.InsertAsync(data).ConfigureAwait(false); rst.ResultData = ObjectMapper.Map <VideoDevOutput>(data); rst.Flag = true; } catch { } return(rst); }
private async Task <RequestResult <VideoDevOutput> > UpdateAsync(EditVideoDevInput input) { var rst = new RequestResult <VideoDevOutput>() { Flag = false }; try { var data = await _repository.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.ResultData = ObjectMapper.Map <VideoDevOutput>(data); rst.Flag = true; } catch { } return(rst); }