public async Task <IActionResult> Edit([FromBody] StationEntity stationEntity, [FromRoute] string id)
        {
            var userId = HttpContext.GetCurrentUserId();

            if (userId is null)
            {
                return(Unauthorized());
            }

            var existing = await _stationRepo.GetAsync(id);

            if (existing is null)
            {
                return(NotFound());
            }

            stationEntity.Id           = Guid.NewGuid().ToString();
            stationEntity.OldStationId = existing.Id;
            stationEntity.UserId       = userId;
            existing.Old = true;

            await _stationRepo.AddAsync(stationEntity);

            var edited = await _stationRepo.GetAsync(stationEntity.Id);

            return(Ok(edited));
        }
        public async Task <IActionResult> Delete([FromRoute] string id)
        {
            var userId = HttpContext.GetCurrentUserId();

            if (userId is null)
            {
                return(Unauthorized());
            }

            var existing = await _stationRepo.GetAsync(id);

            if (existing is null || existing.Deleted || existing.Old)
            {
                return(NotFound());
            }

            var newStation = new StationEntity
            {
                Id           = Guid.NewGuid().ToString(),
                Name         = existing.Name,
                TotalSockets = existing.TotalSockets,
                FreeSockets  = existing.FreeSockets,
                Location     = existing.Location,
                OldStationId = existing.Id,
                OldStation   = existing.OldStation,
                UserId       = userId,
                Deleted      = true,
            };

            existing.Old = true;

            await _stationRepo.AddAsync(newStation);

            return(Ok(newStation));
        }
        public async Task <IActionResult> Add([FromBody] StationEntity station)
        {
            var userId = HttpContext.GetCurrentUserId();

            if (userId is null)
            {
                return(Unauthorized());
            }

            station.Id     = Guid.NewGuid().ToString();
            station.UserId = userId;

            await _stationRepo.AddAsync(station);

            var created = await _stationRepo.GetAsync(station.Id);

            return(Ok(created));
        }