public async Task <bool> Change([FromBody] ErrorRecordChangeStateRequest model) { ErrorChangeRecord coreEntity = _mapper.Map <ErrorChangeRecord>(model); int currentUserId = await _userDataService.UserIdByAccount(User.Identity.Name); coreEntity.ChangedById = currentUserId; ErrorChangeRecord insertedEntity = await _errorChangeDataService.Insert(coreEntity); return(insertedEntity.Id > 0); }
/// <summary> /// Change history status with comment /// </summary> public async Task <ErrorChangeRecord> Insert(ErrorChangeRecord entity) { entity.Date = DateTime.Now; var trackedLinkTask = _dbContext.ErrorChangeRecords.AddAsync(entity); var errorRecordTask = _dbContext.ErrorRecords.FirstAsync(s => s.Id == entity.ErrorRecordId); await Task.WhenAll(trackedLinkTask, errorRecordTask).ConfigureAwait(false); var errorRecord = errorRecordTask.Result; errorRecord.Status = entity.Action; await _rawContext.SaveChangesAsync(); return(trackedLinkTask.Result.Entity); }