Beispiel #1
0
        public IActionResult PutDevice([FromRoute] Guid guid, [FromBody] Domain.Models.DeviceModels.Device device)
        {
            if (guid != device.DeviceId)
            {
                return(BadRequest());
            }

            return(Ok(deviceService.Upsert(device, User)));
        }
        public Domain.Models.DeviceModels.Device CreateTestDevice(string testDeviceName = TestDeviceName)
        {
            var newTestDevice = new Domain.Models.DeviceModels.Device
            {
                DeviceName     = testDeviceName,
                DeviceTypeId   = TestDeviceType.DeviceTypeId,
                ManufacturerId = TestManufacturer.ManufacturerId
            };

            DeviceService.Insert(newTestDevice);
            newTestDevice = DeviceService.Search(testDeviceName).First();
            return(newTestDevice);
        }
        public void InsertDeviceWithNameThatIsSoftDeletedTest()
        {
            TestDevice.IsDeleted = true;
            DeviceService.Update(TestDevice);

            var newDevice = new Domain.Models.DeviceModels.Device {
                DeviceName = TestDeviceName, DeviceTypeId = TestDeviceType.DeviceTypeId
            };

            DeviceService.Upsert(newDevice, TestUserPrincipal);

            var foundDevices = DeviceService.Search(TestDeviceName).ToList();

            Assert.AreEqual(1, foundDevices.Count);
            Assert.AreEqual <string>(foundDevices.First().DeviceName, TestDevice.DeviceName);
            Assert.IsFalse(foundDevices.First().IsDeleted);
        }
        public void CreateNewDeviceWithUpsertTest()
        {
            var newDevice = new Domain.Models.DeviceModels.Device
            {
                DeviceName     = "New Upsert Test Device",
                DeviceTypeId   = TestDeviceType.DeviceTypeId,
                ManufacturerId = TestManufacturer.ManufacturerId
            };

            DeviceService.Upsert(newDevice, TestUserPrincipal);
            var foundDevices = DeviceService.Search("New Upsert Test Device").ToList();

            Assert.AreEqual(1, foundDevices.Count);
            Assert.AreEqual(foundDevices.First().DeviceName, newDevice.DeviceName);

            DeviceService.DeleteByGuid(foundDevices.First().DeviceId);
        }
Beispiel #5
0
 public IActionResult PostDevice([FromBody] Domain.Models.DeviceModels.Device device)
 {
     return(Ok(deviceService.Upsert(device, User)));
 }
 public void DeleteTestDevice(Domain.Models.DeviceModels.Device device)
 {
     DeviceService.DeleteByGuid(device.DeviceId);
 }