private worker_versions MapWorkerVersions(workers workers) { return(new worker_versions { WorkflowState = workers.WorkflowState, Version = workers.Version, CreatedAt = workers.CreatedAt, UpdatedAt = workers.UpdatedAt, MicrotingUid = workers.MicrotingUid, FirstName = workers.FirstName, LastName = workers.LastName, Email = workers.Email, WorkerId = workers.Id }); }
public async Task Delete(MicrotingDbContext dbContext) { workers worker = await dbContext.workers.FirstOrDefaultAsync(x => x.Id == Id); if (worker == null) { throw new NullReferenceException($"Could not find Worker with Id: {Id}"); } worker.WorkflowState = Constants.Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { worker.Version += 1; worker.UpdatedAt = DateTime.UtcNow; dbContext.worker_versions.Add(MapWorkerVersions(worker)); await dbContext.SaveChangesAsync().ConfigureAwait(false); } }
public async Task Update(MicrotingDbContext dbContext) { workers worker = await dbContext.workers.FirstOrDefaultAsync(x => x.Id == Id); if (worker == null) { throw new NullReferenceException($"Could not find Worker with Id: {Id}"); } worker.MicrotingUid = MicrotingUid; worker.FirstName = FirstName; worker.LastName = LastName; worker.Email = Email; if (dbContext.ChangeTracker.HasChanges()) { worker.Version += 1; worker.UpdatedAt = DateTime.UtcNow; dbContext.worker_versions.Add(MapWorkerVersions(worker)); await dbContext.SaveChangesAsync().ConfigureAwait(false); } }