Ejemplo n.º 1
0
        // GET api/projects/{id}/screenshot
        public async Task <HttpResponseMessage> Get(string id)
        {
            await GetProjectAsync(id);

            DomainScreenshot screenshot = await _projectScreenshotService.GetAsync(id);

            var projectScreenshot = new ProjectScreenshot
            {
                Name        = screenshot.FileName,
                Uri         = screenshot.FileUri,
                Length      = screenshot.FileLength,
                ContentType = screenshot.ContentType
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, projectScreenshot);

            response.SetLastModifiedDate(screenshot.Modified);

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets a video viewmodel.
        /// </summary>
        /// <param name="watch">Watch project model.</param>
        /// <param name="id">Project identifier.</param>
        /// <returns></returns>
        protected async Task <VideoModel> GetVideoModel(Watch watch, string id)
        {
            VideoModel video = CreateVideoModel(id);

            video.Video       = watch;
            video.Name        = watch.Name;
            video.Description = watch.Description;

            OverrideParams(video);

            // If screenshot was not overriden
            if (string.IsNullOrEmpty(video.Image))
            {
                // Set default image
                video.Image = watch.Screenshots.Count == 0 ? string.Empty : watch.Screenshots[0].Uri;

                // Try to receive screenshot from the service
                if (String.IsNullOrEmpty(video.Image) || watch.Generator != (int)ProductType.TaggerIPhone)
                {
                    try
                    {
                        DomainScreenshot screenshot = await _screenshotService.GetAsync(id);

                        video.Image = screenshot.FileUri;
                    }
                    catch (NotFoundException)
                    {
                    }
                    catch (Exception e)
                    {
                        Trace.TraceError("Failed to receive project {0} screenshot: {1}", id, e);
                    }
                }
            }

            SetImage(video);

            return(video);
        }