public async Task <OperationResult> Delete(int outerResourceId) { try { var outerResource = new OuterResource() { Id = outerResourceId }; await outerResource.Delete(_dbContext); await _bus.SendLocal(new OuterInnerResourceDelete(null, new OuterResourceModel() { Id = outerResourceId })); return(new OperationResult(true, _localizationService.GetString("OuterResourceDeletedSuccessfully"))); } catch (Exception e) { Trace.TraceError(e.Message); _logger.LogError(e.Message); return(new OperationResult(false, _localizationService.GetString("ErrorWhileDeletingOuterResource"))); } }
public async Task OuterResource_Delete_DoesDelete() { //Arrange OuterResource area = new OuterResource { Name = Guid.NewGuid().ToString() }; DbContext.OuterResources.Add(area); DbContext.SaveChanges(); //Act OuterResource selectedOuterResource = new OuterResource { Id = area.Id }; await selectedOuterResource.Delete(DbContext); OuterResource dbOuterResource = DbContext.OuterResources.AsNoTracking().First(); List <OuterResource> areaList = DbContext.OuterResources.AsNoTracking().ToList(); List <OuterResourceVersion> versionList = DbContext.OuterResourceVersions.AsNoTracking().ToList(); // Assert Assert.NotNull(dbOuterResource); Assert.AreEqual(1, areaList.Count()); Assert.AreEqual(1, versionList.Count()); Assert.AreEqual(dbOuterResource.WorkflowState, Constants.WorkflowStates.Removed); }
public void Area_Delete_DoesSetWorkflowStateToRemoved() { //Arrange OuterResource outerResource = new OuterResource(); outerResource.Name = Guid.NewGuid().ToString(); DbContext.OuterResources.Add(outerResource); DbContext.SaveChanges(); //Act outerResource.Delete(DbContext); OuterResource dbOuterResource = DbContext.OuterResources.AsNoTracking().First(); List <OuterResource> areaList = DbContext.OuterResources.AsNoTracking().ToList(); List <OuterResourceVersion> areaVersions = DbContext.OuterResourceVersions.AsNoTracking().ToList(); //Assert Assert.NotNull(dbOuterResource); Assert.AreEqual(1, areaList.Count()); Assert.AreEqual(1, areaVersions.Count()); Assert.AreEqual(outerResource.Name, dbOuterResource.Name); Assert.AreEqual(outerResource.CreatedAt.ToString(), dbOuterResource.CreatedAt.ToString()); Assert.AreEqual(dbOuterResource.WorkflowState, Constants.WorkflowStates.Removed); Assert.AreEqual(outerResource.Version, dbOuterResource.Version); Assert.AreEqual(outerResource.UpdatedAt.ToString(), dbOuterResource.UpdatedAt.ToString()); Assert.AreEqual(outerResource.CreatedByUserId, dbOuterResource.CreatedByUserId); Assert.AreEqual(outerResource.UpdatedByUserId, dbOuterResource.UpdatedByUserId); }