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);
            }
        }
示例#2
0
        public void DeleteDeviceTest()
        {
            var id =
                _deviceService.Create(GetDevice());

            _deviceService.Delete(id);

            _deviceService.Get(id);
        }
示例#3
0
        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();
        }
示例#5
0
 public async Task <IActionResult> DeleteDevice(string deviceId)
 {
     if (deviceService.Delete(deviceId))
     {
         return(Ok());
     }
     return(NotFound());
 }
示例#6
0
        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>()));
        }
示例#7
0
        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>()));
        }
示例#8
0
        /// <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();
        }
示例#9
0
        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());
        }
示例#10
0
 public void DeleteDevice(string id) // DELETE: api/v1/devices/5
 {
     _deviceService.Delete(id);
 }
示例#11
0
        public ActionResult Delete(int Id)
        {
            OperationResult result = DeviceService.Delete(Id);

            return(Json(result));
        }
示例#12
0
 public void Delete(string id)
 {
     _deviceService.Delete(id);
 }
示例#13
0
        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"));
        }