コード例 #1
0
        public IQueryable <Entity.MetaItem> GetMetaItemsForMediaObjectId(int id)
        {
            // GET /api/mediaitems/12/meta - Gets metadata items for media object #12
            try
            {
                return(GalleryObjectController.GetMetaItemsForMediaObject(id).AsQueryable());
            }
            catch (InvalidMediaObjectException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent(String.Format("Could not find media object with ID = {0}", id)),
                    ReasonPhrase = "Media Object Not Found"
                });
            }
            catch (GallerySecurityException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (Exception ex)
            {
                AppEventController.LogError(ex);

                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = Utils.GetExStringContent(ex),
                    ReasonPhrase = "Server Error"
                });
            }
        }
コード例 #2
0
        public async Task <IActionResult> GetMetaItemsForMediaObjectId(int id)
        {
            // GET /api/mediaitems/meta/12 - Gets metadata items for media object #12
            try
            {
                return(new JsonResult(await _galleryObjectController.GetMetaItemsForMediaObject(id)));
            }
            catch (InvalidMediaObjectException)
            {
                return(NotFound("Media Asset Not Found: Could not find media object with ID {id}."));
            }
            catch (GallerySecurityException)
            {
                return(Forbid());
            }
            catch (Exception ex)
            {
                AppEventController.LogError(ex);

                return(StatusCode(500, _exController.GetExString(ex)));
            }
        }