Exemplo n.º 1
0
        public async Task <IQueryable <Album> > GetAllAlbum()
        {
            string currentUserId = new ConfigModel().DefaultUserId;

            try {
                currentUserId = await ManageUserController.GetUserId(Request, User);
            }
            catch (Exception e) {
                Trace.WriteLine("Invalid auth token: " + e);
            }

            return(Query().Where(x => x.UserId == currentUserId || x.IsDefault));
        }
Exemplo n.º 2
0
        // GET tables/Image
        public async Task <IQueryable <Image> > GetAllImage()
        {
            string defaultUserId = new ConfigModel().DefaultUserId;
            string currentUserId = defaultUserId;

            try {
                currentUserId = await ManageUserController.GetUserId(Request, User);
            }
            catch (Exception e) {
                Trace.WriteLine("Invalid auth token: " + e);
            }

            // return images owned by the current user or the guest user
            return(Query().Where(i => i.UserId == currentUserId || i.UserId == defaultUserId).Where(i => i.IsVisible));
        }
Exemplo n.º 3
0
        // POST tables/Image
        public async Task <IHttpActionResult> PostImage(Image item)
        {
            var config = new ConfigModel();

            if (item.AlbumId == config.DefaultAlbumId)
            {
                item.UserId = config.DefaultUserId; // public album images can be viewed by anyone, so set to the default user

                if (AppSettings.PublicAlbumRequiresAuth)
                {
                    // if not logged in with AAD, images in public album should not be visible
                    item.IsVisible = await ManageUserController.IsAadLogin(Request, User);
                }
            }

            Image current = await InsertAsync(item);

            return(CreatedAtRoute("Tables", new { id = current.Id }, current));
        }