private InnerResourceVersion MapVersions(InnerResource innerResource) { InnerResourceVersion innerResourceVer = new InnerResourceVersion { Name = innerResource.Name, InnerResourceId = innerResource.Id, Version = innerResource.Version, CreatedAt = innerResource.CreatedAt, UpdatedAt = innerResource.UpdatedAt, ExternalId = innerResource.ExternalId }; return(innerResourceVer); }
public async Task Delete(OuterInnerResourcePnDbContext dbContext) { InnerResource innerResource = dbContext.InnerResources.FirstOrDefault(x => x.Id == Id); if (innerResource == null) { throw new NullReferenceException($"Could not find machine with id: {Id}"); } innerResource.WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { innerResource.UpdatedAt = DateTime.Now; innerResource.Version += 1; dbContext.InnerResourceVersions.Add(MapVersions(innerResource)); dbContext.SaveChanges(); } }
public async Task Update(OuterInnerResourcePnDbContext dbContext) { InnerResource innerResource = dbContext.InnerResources.FirstOrDefault(x => x.Id == Id); if (innerResource == null) { throw new NullReferenceException($"Could not find Machine with id: {Id}"); } innerResource.Name = Name; innerResource.ExternalId = ExternalId; if (dbContext.ChangeTracker.HasChanges()) { innerResource.UpdatedAt = DateTime.Now; innerResource.Version += 1; dbContext.InnerResourceVersions.Add(MapVersions(innerResource)); dbContext.SaveChanges(); } }