public FileWatcher([NotNull] FileInfo fileInfo, IRatingService ratingsMetrics, IScheduler scheduler=null)
        {
            FileInfo = fileInfo;
            if (fileInfo == null) throw new ArgumentNullException(nameof(fileInfo));

            scheduler = scheduler ?? Scheduler.Default;

            var refreshRate = ratingsMetrics.Metrics.Take(1)
                .Select(metrics=> TimeSpan.FromMilliseconds(metrics.RefreshRate))
                .Wait();

            var shared = _scanFrom.Select(start => start == 0
                ? fileInfo.WatchFile(scheduler: scheduler, refreshPeriod: refreshRate)
                : fileInfo.WatchFile(scheduler: scheduler, refreshPeriod: refreshRate).ScanFromEnd())
                .Switch();

            Latest = shared
                .TakeWhile(notification => notification.Exists).Repeat()
                .Replay(1).RefCount();

            Status = fileInfo.WatchFile(scheduler: scheduler).Select(notificiation =>
            {
                if (!notificiation.Exists || notificiation.Error != null)
                    return FileStatus.Error;

                return FileStatus.Loaded;
            })
            .StartWith(FileStatus.Loading)
            .DistinctUntilChanged();
        }
 /// <summary>
 /// Initializes a new instance of the ViewModelWorker class
 /// </summary>
 /// <param name="navigationService">NavigationService provided by Caliburn.Micro</param>
 /// <param name="progressService">ProgressService provided by Caliburn.Micro</param>
 /// <param name="eventAggregator">EventAggregator provided by Caliburn.Micro</param>
 /// <param name="storageService">StorageService provided by Caliburn.Micro</param>
 /// <param name="navigationHelperService">NavigationHelperService provided by Caliburn.Micro</param>
 /// <param name="ratingService">RatingService provided by Caliburn.Micro</param>
 /// <param name="diagnosticsService">DiagnosticsService provided by Caliburn.Micro</param>
 public ViewModelWorker(INavigationService navigationService, IProgressService progressService, IEventAggregator eventAggregator, IStorageService storageService, INavigationHelperService navigationHelperService, IRatingService ratingService, IDiagnosticsService diagnosticsService)
 {
     this.navigationService = navigationService;
     this.progressService = progressService;
     this.eventAggregator = eventAggregator;
     this.storageService = storageService;
     this.navigationHelperService = navigationHelperService;
     this.ratingService = ratingService;
     this.diagnosticsService = diagnosticsService;
 }
 public MovieController(IMovieService movieService, ICountryService countryService,
                        IGenreService genreService, IPeopleService peopleService,
                        ICareerService careerService, IUserCommentService userCommentService,
                        IRatingService ratingService)
 {
     _movieService = movieService;
     _countryService = countryService;
     _genreService = genreService;
     _peopleService = peopleService;
     _careerService = careerService;
     _userCommentService = userCommentService;
     _ratingService = ratingService;
 }
Beispiel #4
0
        public GeneralOptionsViewModel(ISetting<GeneralOptions> setting, 
            IRatingService ratingService,
            ISchedulerProvider schedulerProvider)
        {
            var reader = setting.Value.Subscribe(options =>
            {
                UseDarkTheme = options.Theme== Theme.Dark;
                HighlightTail = options.HighlightTail;
                HighlightDuration = options.HighlightDuration;
                Scale = options.Scale;
                Rating = options.Rating;
            });

            RequiresRestart = setting.Value.Select(options => options.Rating)
                                    .HasChanged()
                                    .ForBinding();

            RestartCommand = new ActionCommand(() =>
            {
                Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            });

            var writter = this.WhenAnyPropertyChanged()
                .Subscribe(vm =>
                {
                    setting.Write(new GeneralOptions(UseDarkTheme ? Theme.Dark : Theme.Light, HighlightTail, HighlightDuration, Scale, Rating));
                });

            HighlightDurationText = this.WhenValueChanged(vm=>vm.HighlightDuration)
                                        .DistinctUntilChanged()
                                        .Select(value => value.ToString("0.00 Seconds"))
                                        .ForBinding();

            ScaleText = this.WhenValueChanged(vm => vm.Scale)
                                        .DistinctUntilChanged()
                                        .Select(value => $"{value} %" )
                                        .ForBinding();

            ScaleRatio = this.WhenValueChanged(vm => vm.Scale)
                                    .DistinctUntilChanged()
                                    .Select(value => (decimal) value/(decimal) 100)
                                    .ForBinding();

            _cleanUp = new CompositeDisposable(reader, writter,  HighlightDurationText, ScaleText, ScaleRatio);
        }
        public NetflixRouter(IRatingService ratingService, IRecommendationService recommendationService, int userId)
        {
            Get["titlesById[{ranges:titleIds}]['rating']"] = async parameters =>
            {
                List<int> titleIds = parameters.titleIds;
                var ratings = await ratingService.GetRatingsAsync(titleIds, userId);
                var results = titleIds.Select(titleId =>
                {
                    var rating = ratings.SingleOrDefault(r => r.TitleId == titleId);
                    var path = Path("titlesById", titleId);
                    if (rating == null) return path.Keys("userRating", "rating").Undefined();
                    if (rating.Error) return path.Keys("userRating", "rating").Error(rating.ErrorMessage);
                    return path
                        .Key("userRating").Atom(rating.UserRating)
                        .Key("rating").Atom(rating.Rating);
                });

                return Complete(results);
            };

            Get["genrelist[{integers:indices}].name"] = async parameters =>
            {
                var genreResults = await recommendationService.GetGenreListAsync(userId);
                List<int> indices = parameters.indices;
                var results = indices.SelectMany(index =>
                {
                    var genre = genreResults.ElementAtOrDefault(index); return genre != null
                        ? Path("genrelist", index, "name").Atom(genre.Name, TimeSpan.FromDays(-1))
                        : Path("genrelist", index).Undefined();
                });
                return Complete(results);
            };

            Get["genrelist.mylist"] = async _ =>
            {
                var genreResults = await recommendationService.GetGenreListAsync(userId);
                var myList = genreResults.SingleOrDefault(g => g.IsMyList);
                var index = genreResults.IndexOf(myList);
                return myList != null
                    ? Complete(Path("genrelist", "mylist").Ref("genrelist", index))
                    : Error("myList missing from genrelist");
            };
        }
Beispiel #6
0
 public SeriesService(AppDbContext dbContext,
                      IMapper mapper,
                      IFileStorageService fileStorageService,
                      ILoggerService logger,
                      ICommentService commentService,
                      IAccountsService accountsService,
                      IPeopleService peopleService,
                      IRatingService ratingService,
                      IUserFavoriteService userFavoriteService)
     : base(dbContext)
 {
     _dbContext           = dbContext;
     _mapper              = mapper;
     _fileStorageService  = fileStorageService;
     _logger              = logger;
     _commentService      = commentService;
     _accountsService     = accountsService;
     _peopleService       = peopleService;
     _ratingService       = ratingService;
     _userFavoriteService = userFavoriteService;
 }
Beispiel #7
0
 public ShippingService(
     LoadshopDataContext context,
     IMapper mapper,
     IUserContext userContext,
     ISecurityService securityService,
     ICommonService commonService,
     INotificationService notificationService,
     IRatingService ratingService,
     IDateTimeProvider dateTime,
     ServiceUtilities serviceUtilities)
 {
     _context             = context;
     _mapper              = mapper;
     _serviceUtilities    = serviceUtilities;
     _userContext         = userContext;
     _securityService     = securityService;
     _commonService       = commonService;
     _notificationService = notificationService;
     _ratingService       = ratingService;
     _dateTime            = dateTime;
 }
Beispiel #8
0
        public PlayerController(IPlayerService playerService, IRatingService ratingService, IMapperAdapter mapper)
        {
            if (playerService == null)
            {
                throw new ArgumentNullException("playerService");
            }

            if (ratingService == null)
            {
                throw new ArgumentNullException("ratingService");
            }

            if (mapper == null)
            {
                throw new ArgumentNullException("mapper");
            }

            this.playerService = playerService;
            this.ratingService = ratingService;
            this.mapper        = mapper;
        }
Beispiel #9
0
 public GameController(
     IAsyncViewModelFactory <ModifyGameViewModel, GameViewModel> gameViewModelFactory,
     IAsyncViewModelFactory <GameDto, DisplayGameViewModel> displayGameViewModelFactory,
     IAsyncViewModelFactory <FilterSelectedOptionsViewModel, FilterViewModel> filterViewModelFactory,
     IViewModelFactory <PageOptions, PageOptionsViewModel> pageOptionsViewModelFactory,
     IViewModelFactory <string, GameImageViewModel> gameImageViewModelFactory,
     IGameService gameService,
     IRatingService ratingService,
     ILogger <GameController> logger,
     IMapper mapper)
 {
     _gameService                 = gameService;
     _ratingService               = ratingService;
     _gameViewModelFactory        = gameViewModelFactory;
     _displayGameViewModelFactory = displayGameViewModelFactory;
     _filterViewModelFactory      = filterViewModelFactory;
     _pageOptionsViewModelFactory = pageOptionsViewModelFactory;
     _gameImageViewModelFactory   = gameImageViewModelFactory;
     _logger = logger;
     _mapper = mapper;
 }
Beispiel #10
0
        public void RateDown(object sender, EventArgs e)
        {
            IUnityContainer container     = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
            IRatingService  ratingService = container.Resolve <IRatingService>();

            UserSession userSession = (UserSession)this.Context.Session["userSession"];
            long        userId      = userSession.UserProfileId;

            int ratedValue = ratingService.GetRating(userId, LinkId);

            if (ratedValue >= 0)
            {
                ratingService.Rate(userId, LinkId, -1);
            }
            else
            {
                ratingService.Rate(userId, LinkId, 0);
            }

            //Server.Transfer(Request.Url.AbsolutePath);
            Response.Redirect(Request.Url.AbsoluteUri);
        }
Beispiel #11
0
        public SearchPresenter(ISearchView view, IVenueService venueService, IWishListService wishListService, IRatingService ratingService) : base(view)
        {
            if (venueService == null)
            {
                throw new ArgumentNullException(nameof(venueService));
            }
            this.venueService = venueService;

            if (wishListService == null)
            {
                throw new ArgumentNullException(nameof(wishListService));
            }
            if (ratingService == null)
            {
                throw new ArgumentNullException(nameof(ratingService));
            }
            this.wishListService      = wishListService;
            this.ratingService        = ratingService;
            this.View.QueryEvent     += View_QueryEvent;
            this.View.SaveVenueEvent += View_SaveVenueEvent;
            this.View.UpdateRating   += View_UpdateRating;
        }
Beispiel #12
0
        private void LoadDataContext()
        {
            var shortcutService   = new ShortcutService();
            var actionProvider    = new ActionProvider();
            var messageBoxService = new MessageBoxService();

            var editorController  = SdlTradosStudio.Application.GetController <EditorController>();
            var segmentSupervisor = new SegmentSupervisor(editorController);
            var eventAggregator   = SdlTradosStudio.Application.GetService <IStudioEventAggregator>();

            var rateItViewModel = new RateItViewModel(shortcutService, actionProvider, segmentSupervisor, messageBoxService,
                                                      editorController, eventAggregator);

            _rateItWindow = new RateItView
            {
                DataContext = rateItViewModel
            };

            RatingService = rateItViewModel;

            rateItElementHost.Child = _rateItWindow;
        }
Beispiel #13
0
        public FileMonitor(string fullPath, IRatingService ratingsMetrics, IScheduler scheduler = null)
        {
            if (fullPath == null)
            {
                throw new ArgumentNullException(nameof(fullPath));
            }
            if (ratingsMetrics == null)
            {
                throw new ArgumentNullException(nameof(ratingsMetrics));
            }

            scheduler = scheduler ?? Scheduler.Default;

            var fileInfo = new FileInfo(fullPath);

            var refreshRate = ratingsMetrics.Metrics.Take(1)
                              .Select(metrics => TimeSpan.FromMilliseconds(metrics.RefreshRate))
                              .Wait();

            var fileChanged = fileInfo
                              .WatchFile(scheduler: scheduler, refreshPeriod: refreshRate);
        }
Beispiel #14
0
        private void LoadDataContext()
        {
            var versionService    = new VersionService();
            var shortcutService   = new ShortcutService(versionService);
            var actionProvider    = new ActionProvider();
            var messageBoxService = new MessageBoxService();

            var editorController  = MtCloudApplicationInitializer.EditorController;
            var segmentSupervisor = new SegmentSupervisor(editorController);

            var rateItViewModel = new RateItViewModel(shortcutService, actionProvider, segmentSupervisor, messageBoxService,
                                                      editorController);

            _rateItWindow = new RateItView
            {
                DataContext = rateItViewModel
            };

            RatingService = rateItViewModel;

            rateItElementHost.Child = _rateItWindow;
        }
        public void Setup()
        {
            _gameViewModelFactory        = A.Fake <IAsyncViewModelFactory <ModifyGameViewModel, GameViewModel> >();
            _displayGameViewModelFactory = A.Fake <IAsyncViewModelFactory <GameDto, DisplayGameViewModel> >();
            _filterViewModelFactory      = A.Fake <IAsyncViewModelFactory <FilterSelectedOptionsViewModel, FilterViewModel> >();
            _pageOptionsViewModelFactory = A.Fake <IViewModelFactory <PageOptions, PageOptionsViewModel> >();
            _gameImageViewModelFactory   = A.Fake <IViewModelFactory <string, GameImageViewModel> >();
            _gameService   = A.Fake <IGameService>();
            _ratingService = A.Fake <IRatingService>();
            _logger        = A.Fake <Logger <GameController> >();
            _mapper        = A.Fake <IMapper>();

            _gameController = new GameController(
                _gameViewModelFactory,
                _displayGameViewModelFactory,
                _filterViewModelFactory,
                _pageOptionsViewModelFactory,
                _gameImageViewModelFactory,
                _gameService,
                _ratingService,
                _logger,
                _mapper);
        }
Beispiel #16
0
 public VendorsController(
     IVendorService vendorService, 
     IReviewService reviewService, 
     IPortfolioService portfolioService, 
     IBookService bookService,
     IHistoryService historyService,
     IWorkService workService,
     IContactService contactService,
     IRatingService ratingService,
     INotificationProxy notificationProxy,
     IAnalyticsService analyticsService)
 {
     _vendorService = vendorService;
     _reviewService = reviewService;
     _portfolioService = portfolioService;
     _bookService = bookService;
     _historyService = historyService;
     _workService = workService;
     _contactService = contactService;
     _ratingService = ratingService;
     _notificationProxy = notificationProxy;
     _analyticsService = analyticsService;
 }
        public DataService(IOptions <DatabaseOptions> optionsAccessor, IRatingService ratingService)
        {
            var options = optionsAccessor.Value;

            _ratingService = ratingService;

            // Configure DB and mapping
            _db = new LiteDatabase(options.ConnectionString);
            _db.Mapper.Entity <Player>().Id(p => p.Id);
            _db.Mapper.Entity <Player>().Ignore(p => p.TotalGames);
            _db.Mapper.Entity <Player>().Ignore(p => p.WinRate);
            _db.Mapper.Entity <Match>().Id(m => m.Id);
            _db.Mapper.Entity <Match>().DbRef(m => m.Winners);
            _db.Mapper.Entity <Match>().DbRef(m => m.Losers);

            // Create directory for DB if needed
            var dbFilePath = options.ConnectionString.Contains("Filename=")
                ? options.ConnectionString.SubstringAfter("Filename=").SubstringUntil(";")
                : options.ConnectionString;
            var dbDirPath = Path.GetDirectoryName(dbFilePath);

            Directory.CreateDirectory(dbDirPath);
        }
        public BarController(IMappingService mappingService,
                             IBarsService barsService,
                             IReviewsService reviewsService,
                             IRatingService ratingService,
                             IUserProvider userProvider)
        {
            if (mappingService == null)
            {
                throw new ArgumentNullException("Mapping service cannot be null.");
            }

            if (barsService == null)
            {
                throw new ArgumentNullException("Bars service cannot be null.");
            }

            if (reviewsService == null)
            {
                throw new ArgumentNullException("Reviews service cannot be null.");
            }

            if (ratingService == null)
            {
                throw new ArgumentNullException("Rating service cannot be null.");
            }

            if (userProvider == null)
            {
                throw new ArgumentNullException("User provider cannot be null.");
            }

            this.mappingService = mappingService;
            this.barsService    = barsService;
            this.reviewsService = reviewsService;
            this.ratingService  = ratingService;
            this.userProvider   = userProvider;
        }
 public EmployeeController(IAcademyService academyService,
                           IRoleService roleService,
                           IAcademyProgramService academyProgramService,
                           IStudentService studentService,
                           IMentorService mentorService,
                           ISubjectService subService,
                           IGroupService groupService,
                           IGroupMemberService groupMemberService,
                           ICategoryService categoryService,
                           ISubCategoryService subCategoryService,
                           IRatingService ratingService)
 {
     _academyService        = academyService;
     _roleService           = roleService;
     _academyProgramService = academyProgramService;
     _studentService        = studentService;
     _mentorService         = mentorService;
     _subjectService        = subService;
     _groupService          = groupService;
     _groupMemberService    = groupMemberService;
     _categoryService       = categoryService;
     _subCategoryService    = subCategoryService;
     _ratingService         = ratingService;
 }
Beispiel #20
0
        public string RateDownCss(long linkId)
        {
            if (SessionManager.IsUserAuthenticated(Context))
            {
                UserSession userSession = (UserSession)this.Context.Session["userSession"];
                long        userId      = userSession.UserProfileId;

                IUnityContainer container     = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
                IRatingService  ratingService = container.Resolve <IRatingService>();

                if (ratingService.GetRating(userId, linkId) < 0)
                {
                    return("selected");
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
Beispiel #21
0
 public RatingController(IRatingService ratingService, IMapper mapper)
 {
     _ratingService = ratingService;
     _mapper        = mapper;
 }
Beispiel #22
0
 public PhotoController(IUserService userService, IPhotoService photoService, IRatingService ratingService)
 {
     this.userService   = userService;
     this.photoService  = photoService;
     this.ratingService = ratingService;
 }
        private RatingsController CreateController(IRatingService ratingService)
        {
            var controller = new RatingsController(ratingService);

            return(controller);
        }
Beispiel #24
0
 public RatingController(IRatingService ratingService, ILoggerService logger)
 {
     _ratingService = ratingService;
     _logger        = logger;
 }
 public RatingController(IRatingService ratingService, IFieldService fieldService)
 {
     this.ratingService = ratingService;
     this.fieldService = fieldService;
 }
Beispiel #26
0
 public RateController(IRatingService votingService)
 {
     this.votingService = votingService;
 }
Beispiel #27
0
 public PostController(IPostService postService, IRatingService ratingService)
 {
     this.postService   = postService;
     this.ratingService = ratingService;
 }
Beispiel #28
0
 public HomeController(IExperiencesService experienceService, IRatingService ratingService)
 {
     this.experienceService = experienceService;
     this.ratingService     = ratingService;
 }
Beispiel #29
0
 public OrderController(IAuthService authService, IOrderService orderService, IRatingService ratingService)
 {
     this.authService = authService;
     this.orderService = orderService;
     this.ratingService = ratingService;
 }
Beispiel #30
0
 public RatingController(IRatingService ratingService, IUserService userService, IProductService productService)
 {
     _ratignService  = ratingService;
     _userService    = userService;
     _productService = productService;
 }
Beispiel #31
0
 public RecentActivityViewComponent(IBlogService blogService, IRatingService ratingService)
 {
     _blogService   = blogService;
     _ratingService = ratingService;
 }
 public RatingsAdministrationController(IRatingService ratings, IUserService users, IPetService pets)
 {
     this.ratings = ratings;
     this.users = users;
     this.pets = pets;
 }
Beispiel #33
0
 public PostsController(IPostService postser, IRatingService ratingService)
 {
     _postser       = postser;
     _ratingService = ratingService;
 }
        public RatingModule(IRatingService ratingService, IHttpContextAccessor httpContextAccessor)
        {
            this.ratingService = ratingService;

            Get["/"] = x =>
                           {
                return "Test Route";
            };

            Post["/{TokenKey}/Ratings"] = x =>
                                         {
                                            var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                                            var command = new AddRatingCommand(Request.Form.UniqueKey, uint.Parse(Request.Form.Rating), Request.Form.CustomParams, new AuthorisationContext(x.TokenKey, ipAddress));
                                            this.ratingService.AddRating(command);
                                            return Response.AsJson((string)Request.Form.UniqueKey);
                                        };

            Get["/{TokenKey}/Ratings/Key/{UniqueKey}"] = x =>
            {
                var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                var query = new GetRatingUniqueKeyQuery(new AuthorisationContext(x.TokenKey, ipAddress), x.UniqueKey);
                var ratings = ratingService.GetRatingsByUniqueKey(query);
                var ratingAverages = ratingService.GetAverageRatings(ratings.ToList());
                return this.AsJsonRatings(ratings, ratingAverages);
            };

            Get["/{TokenKey}/Ratings/All"] = x =>
                                         {
                                             var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                                             var query = new GetAllRatingsQuery(new AuthorisationContext(x.TokenKey, ipAddress));
                                             var ratings = ratingService.GetAllRatings(query);
                                             var ratingAverages = ratingService.GetAverageRatings(ratings.ToList());
                                             return this.AsJsonRatings(ratings, ratingAverages);
                                         };

            Get["/{TokenKey}/Ratings/Custom"] = x =>
                                               {
                                                   var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                                                   Dictionary<string, object>.KeyCollection keys = Request.Query.GetDynamicMemberNames();
                                                   var customParam = keys.First();
                                                   var queryParam = Request.Query[customParam];

                                                   var query = new GetRatingsCustomParamQuery(new AuthorisationContext(x.TokenKey, ipAddress), customParam, queryParam);
                                                   var ratings = ratingService.GetRatingsByCustomParam(query);
                                                   var ratingAverages = ratingService.GetAverageRatings(ratings.ToList());
                                                   return this.AsJsonRatings(ratings, ratingAverages);
                                               };

            Get["/{TokenKey}/Ratings/Between/Rating"] = x =>
                                        {
                                            var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                                            var query = new GetRatingsBetweenRatingQuery(new AuthorisationContext(x.TokenKey, ipAddress), Request.Query.minRating, Request.Query.maxRating);
                                            var ratings = this.ratingService.GetRatingsBetweenRating(query);
                                            var ratingAverages = ratingService.GetAverageRatings(ratings.ToList());
                                            return this.AsJsonRatings(ratings, ratingAverages);
                                        };

            Delete["/{TokenKey}/Ratings/{UniqueKey}"] = x =>
                                                       {
                                                           var ipAddress = IPAddress.Parse(httpContextAccessor.Current.Request.UserHostAddress);
                                                           var command = new DeleteRatingCommand(new AuthorisationContext(x.TokenKey, ipAddress), x.UniqueKey);
                                                           return Response.AsJson((int)this.ratingService.DeleteRating(command));
                                                       };

            Put["/{Key}/Ratings/{UniqueKey}"] = x =>
                                                    {
                                                        return null; // TODO:need to update a rating by ID

                                                        string customParams = null;
                                                        if(Request.Form.CustomParams.HasValue)
                                                            customParams = Request.Form.CustomParams;

                                                        uint? rating = null;
                                                        if(Request.Form.Rating.HasValue)
                                                            rating = uint.Parse(Request.Form.Rating);

                                                        var command = new UpdateRatingCommand(x.UniqueKey, rating, customParams, new AccountContext(x.Key));
                                                        return Response.AsJson((int)this.ratingService.UpdateRating(command));
                                                    };
        }
Beispiel #35
0
 public Builder WithRatingService(IRatingService ratingService)
 {
     RatingService = ratingService;
     return(this);
 }
Beispiel #36
0
 public AccountController(IAuthService authService, IAccountService accountService, IRatingService ratingService)
 {
     this.authService = authService;
     this.accountService = accountService;
     this.ratingService = ratingService;
 }
Beispiel #37
0
 public RatingController(IRatingService ratingSer)
 {
     _ratingSer = ratingSer;
 }
 public RatingsController(IRatingService ratings)
 {
     this.ratings = ratings;
 }
Beispiel #39
0
 public RatingsController(IRatingService ratingService)
 {
     this.ratingService = ratingService;
 }
        public NetflixFalcorRouter(IRatingService ratingService, IRecommendationService recommendationService,
            int userId)
        {
            Get["titles[{ranges:indices}]"] = async parameters => {
                List<int> titleIds = parameters.indices;

                var ratings = await ratingService.GetRatingsAsync(titleIds.Select(x => Guid.NewGuid()), userId);
                var results = titleIds.Select(idx => {
                    var rating = ratings.ElementAtOrDefault(idx);
                    var path = Path("titles", idx);
                    if (rating == null) return path.Keys("userRating", "rating").Undefined();
                    if (rating.Error) return path.Keys("userRating", "rating").Error(rating.ErrorMessage);
                    return path
                        .Ref("titlesById", rating.TitleId.ToString());
                });

                return Complete(results);
            };

            Get["titlesById[{ranges:titleIds}]['rating', 'userRating', 'titleId']"] = async parameters =>
            {
                List<int> titleIds = parameters.titleIds;
                var ratings = await ratingService.GetRatingsAsync(titleIds.Select(x => Guid.NewGuid()), userId);
                var results = titleIds.Select(titleId =>
                {
                    var rating = ratings.ElementAtOrDefault(titleId);
                    var path = Path("titlesById", titleId);
                    if (rating == null) return path.Keys("userRating", "rating").Undefined();
                    if (rating.Error) return path.Keys("userRating", "rating").Error(rating.ErrorMessage);
                    return path
                        .Key("userRating").Atom(rating.UserRating, TimeSpan.FromSeconds(-3))
                        .Key("rating").Atom(rating.Rating)
                        .Key("titleId").Atom(rating.TitleId);
                });

                return Complete(results);
            };

            Get["titlesById[{keys:ids}][{keys:props}]"] = async parameters => 
            {
                KeySet idsSet = parameters.ids;
                KeySet propsSet = parameters.props;

                var ids = idsSet.Select(x => Guid.Parse(x.ToString()));
                var ratings = await ratingService.GetRatingsAsync(ids, userId);

                var results = ids.Select(titleId => 
                {
                    var rating = ratings.SingleOrDefault(r => r.TitleId == titleId);
                    var path = Path("titlesById", titleId.ToString());
                    if (rating == null) return path.Keys("userRating", "rating").Undefined();
                    if (rating.Error) return path.Keys("userRating", "rating").Error(rating.ErrorMessage);
                    return path
                        .Key("userRating").Atom(rating.UserRating, TimeSpan.FromSeconds(-3))
                        .Key("rating").Atom(rating.Rating);
                });

                return Complete(results);
            };

            Get["genrelist[{integers:indices}].name"] = async parameters =>
            {
                var genreResults = await recommendationService.GetGenreListAsync(userId);
                List<int> indices = parameters.indices;
                var results = indices.Select(index =>
                {
                    var genre = genreResults.ElementAtOrDefault(index);
                    return genre != null
                        ? Path("genrelist", index, "name").Atom(genre.Name)
                        : Path("genrelist", index).Undefined();
                });
                return Complete(results);
            };

            Get["genrelist.mylist"] = async _ =>
            {
                var genreResults = await recommendationService.GetGenreListAsync(userId);
                var myList = genreResults.SingleOrDefault(g => g.IsMyList);
                var index = genreResults.IndexOf(myList);
                return myList != null
                    ? Complete(Path("genrelist", "mylist").Ref("genrelist", index))
                    : Error("myList missing from genrelist");
            };
        }
 public MovieRatingsController(IRatingService ratingService, IMapper mapper)
 {
     _ratingService = ratingService ?? throw new ArgumentNullException(nameof(ratingService));
     _mapper        = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
 /// <summary>
 /// Initializes a new instance of the VBForumsMetroViewModelWorker class
 /// </summary>
 /// <param name="vbforumsWebService">VBForumsWebService provided by Caliburn.Micro</param>
 /// <param name="vbforumsSterlingService">VBForumsMetroSterlingService provided by Caliburn.Micro</param>
 /// <param name="navigationService">NavigationService provided by Caliburn.Micro</param>
 /// <param name="progressService">ProgressService provided by Caliburn.Micro</param>
 /// <param name="eventAggregator">EventAggregator provided by Caliburn.Micro</param>
 /// <param name="storageService">StorageService provided by Caliburn.Micro</param>
 /// <param name="navigationHelperService">NavigationHelperService provided by Caliburn.Micro</param>
 /// <param name="ratingService">RatingService provided by Caliburn.Micro</param>
 /// <param name="diagnosticsService">DiagnosticsService provided by Caliburn.Micro</param>
 public VBForumsMetroViewModelWorker(IVBForumsWebService vbforumsWebService, ISterlingService vbforumsSterlingService, INavigationService navigationService, IProgressService progressService, IEventAggregator eventAggregator, IStorageService storageService, INavigationHelperService navigationHelperService, IRatingService ratingService, IDiagnosticsService diagnosticsService)
     : base(navigationService, progressService, eventAggregator, storageService, navigationHelperService, ratingService, diagnosticsService)
 {
     this.vbforumsWebService = vbforumsWebService;
     this.vbforumsSterlingService = vbforumsSterlingService;
 }
        public static void MyClassInitialize(TestContext testContext)
        {
            container = TestManager.ConfigureUnityContainer("unity");

            ratingService = container.Resolve <IRatingService>();
        }
Beispiel #44
0
    protected void Page_Load(object sender, EventArgs e)
    {
        i18n = new i18nHelper();
        this.Title = i18n.GetMessage("m261") + " @ " + i18n.GetMessage("m9");
        this.forwardSend.Text = i18n.GetMessage("m78");
        currentUser = WebUtility.GetCurrentKBUser();
        subjectid = currentUser.SubjectId;
        documentService = factory.GetDocumentService();
        categoryService = factory.GetCategoryService();
        ratingService = factory.GetRatingService();
        auditTrailService = factory.GetAuditTrailService();
        wfService = factory.GetWorkflowService();
        hitService = factory.GetHitService();
        documentClassService = factory.GetDocumentClassService();
        subscribeService = WebUtility.Repository.GetSubscribeService();
        docId = WebUtility.GetIntegerParameter("documentId");
        folderId = WebUtility.GetIntegerParameter("folderId", -1);
        ver = WebUtility.GetIntegerParameter("ver", 0);
        latestVersionNumber = buildVersionInfo();
        currentUserOutputConfig = WebUtility.GetUserOutputConfig(currentUser.SubjectId);
        attachMode = currentUserOutputConfig.AttachMode;
        showUsedTags = ConfigurationManager.AppSettings["ShowUsedTags"] != null ? ConfigurationManager.AppSettings["ShowUsedTags"] : "false";
        tagsAutoComplete = ConfigurationManager.AppSettings["TagsAutoComplete"] != null ? ConfigurationManager.AppSettings["TagsAutoComplete"] : "false";
        tagsSuggestListLen = ConfigurationManager.AppSettings["TagsSuggestListLen"] != null ? ConfigurationManager.AppSettings["TagsSuggestListLen"] : "10";
        subscriptionConfirm = Convert.ToBoolean(ConfigurationManager.AppSettings["SubscriptionConfirm"] != null ? ConfigurationManager.AppSettings["SubscriptionConfirm"].ToString() : "true");
        autoSubscription = Convert.ToBoolean(ConfigurationManager.AppSettings["AutoSubscription"] != null ? ConfigurationManager.AppSettings["AutoSubscription"].ToString() : "true");
        allowSendToNoPrivilegeUser = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"] != null ? ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"].ToString() : "true");
        TagMaxLength = ConfigurationManager.AppSettings["TagMaxLength"] != null ? ConfigurationManager.AppSettings["TagMaxLength"] : "30";
        IsSafari = (Request.Browser.Browser.ToLower().Equals("applemac-safari") && !Request.UserAgent.ToLower().Contains("chrome"));
        userHadSubscribeResource = subscribeService.UserHadSubscribedResource(currentUser.SubjectId, (int)currentUser.SubjectType, docId, (int)SubscribeRecord.ResourceType.Document);
        mailService = WebUtility.Repository.GetMailService();
        kbuserService = WebUtility.Repository.GetKBUserService();
        folderService = WebUtility.Repository.GetFolderService();
        forwardService = WebUtility.Repository.GetForwardService();
        if (ver == 0)
        {
            doc = documentService.GetDocument(currentUser, docId);
            ver = latestVersionNumber;
        }
        else
        {
            doc = documentService.GetDocument(currentUser, docId, ver);
        }
        readVersion.Text = ver.ToString();
        latestVersion.Text = latestVersionNumber.ToString();
        if (ver != latestVersionNumber)
        {
            Panel1.Visible = false;
        }
        if (folderId == -1)
        {
            FolderInfo f = documentService.GetParentFolders(currentUser, docId)[0];
            folderId = f.FolderId;
        }

        buildCategoriesList();
        buildDocumentView();

        #region For teamKube Xml Render
        if (IsACLiteSubjectProvider)
        {
            renderSpecXml = RenderSpecificXML(currentUser, doc.DocumentId, ver);
        }
        #endregion

        if(!doc.DocumentClass.ClassName.Trim().ToLower().Equals("filesystem"))
        {
            buildFileList();
        }

        buildRatingSummary();
        buildAuditTrailInfo();
        createHitInfo();
        buildRelatedTagList(20);
        buildRelatedDocumentList();
        checkWorkflowInvolved();
        isDiffDocClass = IsDiffDocumentClass();
        strDiffDocClass = String.Format(i18n.GetMessage("m801"), doc.DocumentClass.ClassName, i18n.GetMessage("m802"), i18n.GetMessage("m803"));

        isBuiltinDocumentClass = (doc.DocumentClass.IsBuiltIn == true) ? "true" : "false";
    }
 public RatingController(IRatingService ratingService)
 {
     _ratingService = ratingService;
 }
Beispiel #46
0
 /// <summary>
 /// Initializes a new instance of the RatingController class.
 /// </summary>
 /// <param name="ratingService">Instance of Rating Service</param>
 /// <param name="profileService">Instance of profile Service</param>
 public RatingController(IRatingService ratingService, IProfileService profileService)
     : base(profileService)
 {
     _ratingService = ratingService;
 }