private bool RemoveDev(DevEntity dev) { if (MessageBox.Show("确认删除设备:" + dev.Name + "?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var r = devService.Delete(dev.Id + ""); if (r == null) { MessageBox.Show("删除失败"); return(false); } var area = AreaCanvas1.CurrentArea; area.RemoveLeafNode(dev.Id); AreaCanvas1.RemoveDev(dev.Id); var topoTree = ResourceTreeView1.TopoTree; topoTree.RemoveDevNode(dev.Id); return(true); //topoTree.RefreshNode(dev.ParentId); //ResourceTreeView1.TopoTree.RemoveCurrentNode(); } else { return(false); } }
public void DeleteDeviceTest() { var id = _deviceService.Create(GetDevice()); _deviceService.Delete(id); _deviceService.Get(id); }
private void RemoveDev(DevEntity dev) { if (MessageBox.Show("确认删除设备:" + dev.Name + "?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var r = devService.Delete(dev.Id + ""); if (r == null) { MessageBox.Show("删除失败"); } AreaCanvas1.RemoveDev(dev.Id); //topoTree.RefreshNode(dev.ParentId); //ResourceTreeView1.TopoTree.RemoveCurrentNode(); } }
/// <summary> /// Handles the Delete event of the gDevice control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param> protected void gDevice_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); DeviceService DeviceService = new DeviceService(rockContext); Device Device = DeviceService.Get(e.RowKeyId); if (Device != null) { int deviceId = Device.Id; string errorMessage; if (!DeviceService.CanDelete(Device, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } DeviceService.Delete(Device); rockContext.SaveChanges(); Rock.CheckIn.KioskDevice.Remove(deviceId); } BindGrid(); }
public async Task <IActionResult> DeleteDevice(string deviceId) { if (deviceService.Delete(deviceId)) { return(Ok()); } return(NotFound()); }
public async void Delete() { var mock = new ServiceMockFacade <IDeviceRepository>(); var model = new ApiDeviceRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new DeviceService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeviceMapperMock, mock.DALMapperMockFactory.DALDeviceMapperMock, mock.BOLMapperMockFactory.BOLDeviceActionMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IDeviceService, IDeviceRepository>(); var model = new ApiDeviceServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new DeviceService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Object, mock.DALMapperMockFactory.DALDeviceMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DeviceDeletedNotification>(), It.IsAny <CancellationToken>())); }
/// <summary> /// Handles the Delete event of the gDevice control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param> protected void gDevice_Delete(object sender, RowEventArgs e) { RockTransactionScope.WrapTransaction(() => { DeviceService DeviceService = new DeviceService(); Device Device = DeviceService.Get((int)e.RowKeyValue); if (Device != null) { string errorMessage; if (!DeviceService.CanDelete(Device, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } DeviceService.Delete(Device, CurrentPersonId); DeviceService.Save(Device, CurrentPersonId); } }); BindGrid(); }
public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <IDeviceService, IDeviceRepository>(); var model = new ApiDeviceServerRequestModel(); var validatorMock = new Mock <IApiDeviceServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new DeviceService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALDeviceMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DeviceDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
public void DeleteDevice(string id) // DELETE: api/v1/devices/5 { _deviceService.Delete(id); }
public ActionResult Delete(int Id) { OperationResult result = DeviceService.Delete(Id); return(Json(result)); }
public void Delete(string id) { _deviceService.Delete(id); }
public async void Invalid_Id_Throws_Error_On_Delete() { var gatewayResult = await service.Delete(0); Assert.True(gatewayResult.Messages != null && gatewayResult.Messages.Contains("Element to delete not found")); }