public IActionResult GetCameras()
        {
            var cameras = _roadwaysCameras.Fetch(null);

            if (cameras.Count <= 0)
            {
                return(StatusCode(404));
            }
            return(new JsonResult(cameras));
        }
Beispiel #2
0
        /// adds a new favorite and returns the entire list.
        public (List <Favorite> cameras, bool success) Add(string userName, int cameraId, string title)
        {
            if (!_roadwaysCameras.Contains(cameraId))
            {
                return(cameras : Fetch(userName), success : false);
            }

            if (!_favorites.ContainsKey(userName))
            {
                _favorites.Add(userName, new Dictionary <Guid, Favorite>());
            }

            var camera = _roadwaysCameras.Fetch(cameraId);

            var guid = Guid.NewGuid();

            _favorites[userName].Add(guid, new Favorite()
            {
                Id       = guid
                , Camera = camera
                , Title  = title.NullIf() ?? camera.Title
            });
            return(cameras : Fetch(userName), success : true);
        }