public async Task<ActionResult> Unit(int id)
        {
            var measurementUnits = await measurementUnitRepository.FindAll();

            CreateUnit model = new CreateUnit
            {
                DeviceId = id,
                MeasurementUnits = measurementUnits.ToSelectListItems(1)
            };

            return View("Unit", model);
        }
        public async Task<ActionResult> Unit(CreateUnit model)
        {
            if (model == null || !ModelState.IsValid)
            {
                ModelState.AddModelError("", "Failed to add unit to device.");
                return View("Unit", model);
            }

            Unit unit = new Unit
            {
                Name = model.Name,
                DeviceId = model.DeviceId,
                MeasurementUnitId = model.MeasurementUnitId
            };

            await deviceRepository.CreateAsync(unit);

            return RedirectToAction("Details", new { id = unit.DeviceId });
        }