コード例 #1
0
        public async Task ImportByModel_Test()
        {
            var testingModel = DeviceImport_TestData.GetTestImportModel();
            var testImport   = await testingInstance.ImportByModelAsync(testingModel);

            var expectedDevices     = testingModel.Devices.OrderBy(x => x.Id).ToList();
            var devicesInRepository = await devicesRepository.GetAllAsync();

            var devicesInRepositorySorted = devicesInRepository.OrderBy(x => x.Id).ToList();

            Assert.Equal(expectedDevices, devicesInRepositorySorted);
        }
コード例 #2
0
        public async Task <IActionResult> Get(int?id = null)
        {
            if (!id.HasValue)
            {
                var allDevices = await devicesRepository.GetAllAsync();

                return(Ok(allDevices));
            }
            else
            {
                var findDevice = await devicesRepository.FindByIdAsync(id.Value);

                if (findDevice == null)
                {
                    return(NotFound("This device does not exist!"));
                }

                return(Ok(findDevice));
            }
        }