public async Task <IActionResult> Add([FromBody] ClosedWaterSupplyInstallation closedWaterSupplyInstallation)
        {
            StateOfTheSystem stateOfTheSystem = new StateOfTheSystem();

            stateOfTheSystem.ClosedWaterSupplyInstallation = closedWaterSupplyInstallation;
            stateOfTheSystem.Temperature     = 0f;
            stateOfTheSystem.OxygenLevel     = 0f;
            stateOfTheSystem.DateOfLastCheck = DateTime.Now;

            await this.repository.AddAsync <StateOfTheSystem>(stateOfTheSystem);

            StateOfTheSystem oldStateOfTheSystem = await this.repository.GetAsync <StateOfTheSystem>(true, x => x.ClosedWaterSupplyInstallation ==
                                                                                                     closedWaterSupplyInstallation);

            int stateOfTheSystemId = oldStateOfTheSystem.StateOfTheSystemId;

            closedWaterSupplyInstallation.StateOfTheSystemId = stateOfTheSystemId;
            closedWaterSupplyInstallation.StateOfTheSystem   = stateOfTheSystem;
            await this.repository.AddAsync <ClosedWaterSupplyInstallation>(closedWaterSupplyInstallation);


            Organization organization = await this.repository.GetAsync <Organization>(true, x => x.OrganizationId ==
                                                                                      closedWaterSupplyInstallation.OrganizationId);

            organization.ClosedWaterSupplyInstallations.Add(closedWaterSupplyInstallation);
            await this.repository.UpdateAsync <Organization>(organization);

            return(this.Ok());
        }
        public async Task <IActionResult> Update([FromBody] StateOfTheSystem stateOfTheSystem)
        {
            var currentStateOfTheSystem = await this.repository.GetAsync <StateOfTheSystem>(true, x => x.StateOfTheSystemId == stateOfTheSystem.StateOfTheSystemId);

            if (currentStateOfTheSystem == null)
            {
                throw new Exception("StateOfTheSystem not found.");
            }
            currentStateOfTheSystem.Temperature     = stateOfTheSystem.Temperature;
            currentStateOfTheSystem.OxygenLevel     = stateOfTheSystem.OxygenLevel;
            currentStateOfTheSystem.DateOfLastCheck = stateOfTheSystem.DateOfLastCheck;
            await this.repository.UpdateAsync <StateOfTheSystem>(currentStateOfTheSystem);

            return(this.Ok());
        }
        public async Task <IActionResult> Add([FromBody] StateOfTheSystem stateOfTheSystem)
        {
            await this.repository.AddAsync <StateOfTheSystem>(stateOfTheSystem);

            return(this.Ok());
        }