private static List<Watch> GetWatches(IEnumerable<ProjectEntity> lastProjects) { var list = new List<Watch>(); foreach (ProjectEntity project in lastProjects) { if (list.Count == ProjectCount) { break; } if (string.IsNullOrEmpty(project.ScreenshotFileId)) { continue; } var watch = new Watch { ScreenshotUrl = project.ScreenshotFileId, Generator = project.ProductId, Id = project.Id, Name = project.Name }; list.Add(watch); } return list; }
/// <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; }
public async Task SendAbuseNotificationAsync(Watch project, DomainUser reporter) { if (project == null) { throw new ArgumentNullException("project"); } if (reporter == null) { throw new ArgumentNullException("reporter"); } if (!_settings.EmailNotifications) { return; } string projectUri = _projectUriProvider.GetUri(project.Id); var email = new SendEmailDomain { Address = _settings.EmailAddressAlerts, DisplayName = Emails.SenderDisplayName, Emails = new List<string> { _settings.EmailAddressAbuse }, Subject = string.Format(Emails.SubjectAbuseReport, projectUri), Body = string.Format( PortalResources.AbuseReported, reporter.Name, _userUriProvider.GetUri(reporter.Id), project.Name, projectUri) }; // Send email await _emailSenderService.SendEmailAsync(email); }