public async Task <IActionResult> CreateOrUpdateDevice([FromBody] CreateOrUpdateDeviceDTO device)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState)); //400
                }

                var createDev = _mapper.Map <Device>(device);

                if (device.Id != null)
                {
                    await _repository.UpdateDevice(createDev);
                }
                else
                {
                    await _repository.CreateDevice(createDev);
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
        public async Task Test_Try_To_Create_Null_Device()
        {
            CreateOrUpdateDeviceDTO device = null;

            var mockRepository = new Mock <IDeviceRepository>();
            var mockMapper     = new Mock <IMapper>();

            var deviceController = new DeviceController(mockRepository.Object, mockMapper.Object);

            var actionResult = await deviceController.CreateOrUpdateDevice(device) as BadRequestObjectResult;

            Assert.Equal(400, actionResult.StatusCode);
        }
        public async Task Test_Create_Device()
        {
            var device = new CreateOrUpdateDeviceDTO
            {
                Name         = "Testing Device",
                DeviceTypeId = 100
            };

            var mockRepository = new Mock <IDeviceRepository>();
            var mockMapper     = new Mock <IMapper>();

            var deviceController = new DeviceController(mockRepository.Object, mockMapper.Object);

            var actionResult = await deviceController.CreateOrUpdateDevice(device);

            var x = actionResult as OkResult;

            Assert.Equal(200, x.StatusCode);
        }