public RatingFilterDialog(FSpot.PhotoQuery query, Gtk.Window parent_window) : base("RatingFilterDialog.ui", "rating_filter_dialog") { TransientFor = parent_window; DefaultResponse = ResponseType.Ok; ok_button.GrabFocus(); if (query.RatingRange != null) { minrating_value = (int)query.RatingRange.MinRating; maxrating_value = (int)query.RatingRange.MaxRating; } minrating = new RatingEntry(minrating_value); maxrating = new RatingEntry(maxrating_value); minrating_hbox.PackStart(minrating, false, false, 0); maxrating_hbox.PackStart(maxrating, false, false, 0); minrating.Show(); maxrating.Show(); minrating.Changed += HandleMinratingChanged; maxrating.Changed += HandleMaxratingChanged; ResponseType response = (ResponseType)Run(); if (response == ResponseType.Ok) { query.RatingRange = new RatingRange((uint)minrating.Value, (uint)maxrating.Value); } Destroy(); }
public RatingQueryValueEntry() : base() { entry = new RatingEntry(); entry.AlwaysShowEmptyStars = true; entry.Changed += HandleValueChanged; Add(entry); }
public async Task AddRating(RatingEntry rating) { try { await _context.Ratings.InsertOneAsync(rating); } catch (Exception ex) { throw ex; } }
public async void RatingRepository_Post_NullRating_Failure() { RatingEntry _rating = null; _mockContext.Setup(p => p.RatingsCollectionName).Returns("ratings"); _mockContext.Setup(p => p.ConnectionString).Returns("mongodb://localhost:27017"); _mockContext.Setup(p => p.DatabaseName).Returns("RatingDB"); var ratingRepository = new RatingRepository(_mockContext.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => ratingRepository.AddRating(_rating)); }
public async Task UpdateRating(string id, RatingEntry rating) { try { await _context.Ratings.ReplaceOneAsync(rating => rating.Id == id, rating); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Delete(string id) { RatingEntry requestedMovie = await _repository.GetById(id); if (requestedMovie == null) { return(NotFound()); } await _repository.DeleteRating(id); return(NoContent()); }
protected virtual void Dispose(bool disposing) { if (disposed) { return; } disposed = true; if (disposing) { Preferences.SettingChanged -= OnPreferencesChanged; // free managed resources if (rating != null) { rating.Dispose(); rating = null; } if (description_entry != null) { description_entry.Dispose(); description_entry = null; } if (tag_view != null) { tag_view.Dispose(); tag_view = null; } if (photo_view_scrolled != null) { photo_view_scrolled.Dispose(); photo_view_scrolled = null; } if (filmstrip != null) { filmstrip.Dispose(); filmstrip = null; } if (inner_vbox != null) { inner_vbox.Dispose(); inner_vbox = null; } if (inner_hbox != null) { inner_hbox.Dispose(); inner_hbox = null; } } // free unmanaged resources }
public async Task <IActionResult> Update(string id, RatingEntry rating) { if (id != rating.Id) { return(BadRequest()); } RatingEntry requestedMovie = await _repository.GetById(id); if (requestedMovie == null) { return(NotFound()); } await _repository.UpdateRating(id, rating); return(NoContent()); }
private bool GrantGiftsIfNone(RatingEntry entry, CourseSettings courseSettings, string courseId) { string sid = entry.User.Logins.First(login => login.LoginProvider == "Контур.Паспорт").ProviderKey; var staffUserId = staffClient.GetUser(sid)["id"].Value <int>(); var gifts = staffClient.GetUserGifts(staffUserId); var giftImagePath = courseSettings.giftImagePath; bool hasComplexityGift = gifts["entries"].Children().Any(gift => gift["giftImagePath"].Value <string>() == giftImagePath); if (!hasComplexityGift) { log.Info($"NoGiftYet\t{entry.Score}\t{entry.User.VisibleName}"); staffClient.GrantGift(staffUserId, entry.Score, courseSettings); log.Info($"ComplexityGiftGrantedFor\t{entry.User.VisibleName}\t{entry.User.KonturLogin}"); telegramBot.PostToChannel($"Granted gift for course {courseId}\n{entry.Score} points for user {entry.User.VisibleName} {entry.User.KonturLogin}"); return(true); } return(false); }
public virtual void OnRatingUpdated(RatingScreenlet screenlet, RatingEntry rating) { Console.WriteLine($"Rating updated: {rating.Average}"); }
public virtual void OnRatingRetrieve(RatingScreenlet screenlet, RatingEntry rating) { Console.WriteLine($"Rating retrive: {rating.Attributes}"); }
public virtual void OnRatingDeleted(RatingScreenlet screenlet, RatingEntry rating) { Console.WriteLine("Rating delete"); }
private void BuildWidgets() { var hbox = new HBox() { Spacing = 12 }; // Left box - cover art, title, etc var left_box = new VBox() { BorderWidth = 12, Spacing = 12 }; // Cover art cover = new BookCover(this) { WidthRequest = 256, HeightRequest = 256 }; var editable_cover = CoverArtEditor.For( cover, (x, y) => true, () => library.TrackModel[0], UpdateCover ); // Title title_label = new WrapLabel(); resume_button = new ImageButton("", null, IconSize.LargeToolbar); resume_button.ImageWidget.Stock = Stock.MediaPlay; resume_button.LabelWidget.Xalign = 0; resume_button.Spacing = 6; // FIXME the left padding on this is not right rating_entry = new RatingEntry() { AlwaysShowEmptyStars = true, HasFrame = false }; var rating = new HBox(); rating.PackStart(rating_entry, false, false, 0); // Packing left_box.PackStart(editable_cover, false, false, 0); left_box.PackStart(title_label, false, false, 0); left_box.PackStart(resume_button, false, false, 0); //left_box.PackStart (rating, false, false, 0); hbox.PackStart(left_box, false, false, 0); // Right box - track list track_list = new BaseTrackListView() { HeaderVisible = true, IsEverReorderable = false }; var columns = new DefaultColumnController(); var file_columns = new ColumnController(); var disc_column = DefaultColumnController.Create( BansheeQuery.DiscNumberField, 0.02, false, new ColumnCellPositiveInt(null, false, 2, 2)); file_columns.AddRange( columns.IndicatorColumn, disc_column, columns.TitleColumn, columns.DurationColumn ); file_columns.SortColumn = columns.DiscNumberAndCountColumn; foreach (var col in file_columns) { col.Visible = true; } var track_sw = new Gtk.ScrolledWindow() { Child = track_list, ShadowType = ShadowType.None }; track_list.ColumnController = file_columns; hbox.PackEnd(track_sw, true, true, 0); Child = hbox; }
private void SetupListView() { _reference.uninstallerObjectListView.VirtualMode = false; _reference.olvColumnDisplayName.AspectName = ApplicationUninstallerEntry.RegistryNameDisplayName; _reference.olvColumnDisplayName.GroupKeyGetter = ListViewDelegates.GetFirstCharGroupKeyGetter; _reference.olvColumnDisplayName.ImageGetter = _iconGetter.ColumnImageGetter; _reference.olvColumnStartup.AspectGetter = x => { var obj = x as ApplicationUninstallerEntry; return((obj?.StartupEntries != null && obj.StartupEntries.Any()).ToYesNo()); }; _reference.olvColumnPublisher.AspectName = ApplicationUninstallerEntry.RegistryNamePublisher; _reference.olvColumnPublisher.GroupKeyGetter = ListViewDelegates.ColumnPublisherGroupKeyGetter; _reference.olvColumnDisplayVersion.AspectName = ApplicationUninstallerEntry.RegistryNameDisplayVersion; _reference.olvColumnDisplayVersion.GroupKeyGetter = ListViewDelegates.DisplayVersionGroupKeyGetter; _reference.olvColumnUninstallString.AspectName = ApplicationUninstallerEntry.RegistryNameUninstallString; _reference.olvColumnUninstallString.GroupKeyGetter = ListViewDelegates.ColumnUninstallStringGroupKeyGetter; _reference.olvColumnInstallDate.AspectGetter = x => { var obj = x as ApplicationUninstallerEntry; return(obj?.InstallDate.Date ?? DateTime.MinValue); }; //_reference.olvColumnInstallDate.AspectName = ApplicationUninstallerEntry.RegistryNameInstallDate; _reference.olvColumnInstallDate.AspectToStringConverter = x => { var entry = (DateTime)x; return(entry.IsDefault() ? Localisable.Empty : entry.ToShortDateString()); }; _reference.olvColumnGuid.AspectGetter = ListViewDelegates.ColumnGuidAspectGetter; _reference.olvColumnGuid.GroupKeyGetter = ListViewDelegates.ColumnGuidGroupKeyGetter; _reference.olvColumnSystemComponent.AspectName = ApplicationUninstallerEntry.RegistryNameSystemComponent; _reference.olvColumnSystemComponent.AspectToStringConverter = ListViewDelegates.BoolToYesNoAspectConverter; _reference.olvColumnSystemComponent.GroupKeyToTitleConverter = ListViewDelegates.BoolToYesNoAspectConverter; _reference.olvColumnIs64.AspectGetter = y => (y as ApplicationUninstallerEntry)?.Is64Bit.GetLocalisedName(); _reference.olvColumnProtected.AspectToStringConverter = ListViewDelegates.BoolToYesNoAspectConverter; _reference.olvColumnProtected.GroupKeyToTitleConverter = ListViewDelegates.BoolToYesNoAspectConverter; _reference.olvColumnInstallLocation.AspectName = ApplicationUninstallerEntry.RegistryNameInstallLocation; _reference.olvColumnInstallLocation.GroupKeyGetter = ListViewDelegates.ColumnInstallLocationGroupKeyGetter; _reference.olvColumnInstallSource.AspectName = ApplicationUninstallerEntry.RegistryNameInstallSource; _reference.olvColumnInstallSource.GroupKeyGetter = ListViewDelegates.ColumnInstallSourceGroupKeyGetter; _reference.olvColumnRegistryKeyName.AspectName = "RegistryKeyName"; _reference.olvColumnUninstallerKind.AspectGetter = y => (y as ApplicationUninstallerEntry)?.UninstallerKind.GetLocalisedName(); _reference.olvColumnAbout.AspectName = "AboutUrl"; _reference.olvColumnAbout.GroupKeyGetter = x => { var entry = x as ApplicationUninstallerEntry; if (string.IsNullOrEmpty(entry?.AboutUrl)) { return(Localisable.Empty); } return(entry.GetUri()?.Host ?? CommonStrings.Unknown); }; _reference.olvColumnQuietUninstallString.AspectName = ApplicationUninstallerEntry.RegistryNameQuietUninstallString; _reference.olvColumnQuietUninstallString.GroupKeyGetter = ListViewDelegates.ColumnQuietUninstallStringGroupKeyGetter; _reference.olvColumnSize.TextAlign = HorizontalAlignment.Right; _reference.olvColumnSize.AspectGetter = ListViewDelegates.ColumnSizeAspectGetter; _reference.olvColumnSize.AspectToStringConverter = ListViewDelegates.AspectToStringConverter; _reference.olvColumnSize.GroupKeyGetter = ListViewDelegates.ColumnSizeGroupKeyGetter; _reference.olvColumnSize.GroupKeyToTitleConverter = x => x.ToString(); // Rating stuff _reference.olvColumnRating.AspectGetter = x => { var entry = x as ApplicationUninstallerEntry; return(string.IsNullOrEmpty(entry?.RatingId) ? RatingEntry.NotAvailable : _ratingManager.GetRating(entry.RatingId)); }; _reference.olvColumnRating.Renderer = new RatingRenderer(); _reference.olvColumnRating.GroupKeyGetter = x => { var model = x as ApplicationUninstallerEntry; if (!_settings.Settings.MiscUserRatings || string.IsNullOrEmpty(model?.RatingId) || _ratingManager.RatingCount <= 0) { return(Localisable.NotAvailable); } var rating = _ratingManager.GetRating(model.RatingId); if (rating.IsEmpty || (!rating.AverageRating.HasValue && !rating.MyRating.HasValue)) { return(CommonStrings.Unknown); } return((rating.MyRating.HasValue ? "Your rating:" : "Average rating:") + " " + RatingEntry.ToRating(rating.MyRating ?? (int)rating.AverageRating)); }; _reference.uninstallerObjectListView.CellClick += (x, y) => { if (y.Column == null || (y.ModifierKeys != Keys.None) || !y.Column.Equals(_reference.olvColumnRating)) { return; } var model = y.Model as ApplicationUninstallerEntry; if (model == null) { return; } RateEntries(new[] { model }, _reference.uninstallerObjectListView.PointToScreen(y.Location)); }; // Rating stuff end _reference.uninstallerObjectListView.PrimarySortColumn = _reference.olvColumnDisplayName; _reference.uninstallerObjectListView.SecondarySortColumn = _reference.olvColumnPublisher; _reference.uninstallerObjectListView.Sorting = SortOrder.Ascending; _reference.uninstallerObjectListView.AdditionalFilter = new ModelFilter(ListViewFilter); _reference.uninstallerObjectListView.UseFiltering = true; _reference.uninstallerObjectListView.FormatRow += UninstallerObjectListView_FormatRow; UninstallerPostprocessingProgressUpdate += (x, y) => { lock (_objectsToUpdate) { if (y.Tag != null) { _objectsToUpdate.Add(y.Tag); } if (y.Value == y.Maximum || y.Value % 35 == 0) { try { _listView.ListView.RefreshObjects(_objectsToUpdate); } catch (InvalidOperationException ex) { // The list view got disposed before we could update it. _abortPostprocessingThread = true; Debug.Fail(ex.Message, ex.StackTrace); } _objectsToUpdate.Clear(); } } }; _listView.ListView.AfterSorting += (x, y) => { AfterFiltering?.Invoke(x, y); }; }
public PhotoView(IBrowsableCollection query) { Query = query; commit_delay = new DelayedOperation(1000, new GLib.IdleHandler(CommitPendingChanges)); Destroyed += HandleDestroy; Name = "ImageContainer"; Box vbox = new VBox(false, 6); Add(vbox); background = new EventBox(); Frame frame = new Frame(); background.Add(frame); frame.ShadowType = ShadowType.In; vbox.PackStart(background, true, true, 0); inner_vbox = new VBox(false, 2); inner_hbox = new HBox(false, 2); frame.Add(inner_hbox); BrowsablePointer bp = new BrowsablePointer(query, -1); View = new PhotoImageView(bp); filmstrip = new Filmstrip(bp); filmstrip.ThumbOffset = 1; filmstrip.Spacing = 4; filmstrip.ThumbSize = 75; PlaceFilmstrip((Orientation)Preferences.Get <int> (Preferences.FILMSTRIP_ORIENTATION), true); View.PhotoChanged += HandlePhotoChanged; photo_view_scrolled = new ScrolledWindow(null, null); photo_view_scrolled.SetPolicy(PolicyType.Automatic, PolicyType.Automatic); photo_view_scrolled.ShadowType = ShadowType.None; photo_view_scrolled.Add(View); photo_view_scrolled.Child.ButtonPressEvent += HandleButtonPressEvent; View.AddEvents((int)EventMask.KeyPressMask); inner_vbox.PackStart(photo_view_scrolled, true, true, 0); inner_hbox.PackStart(inner_vbox, true, true, 0); HBox lower_hbox = new HBox(false, 2); //inner_hbox.BorderWidth = 6; tag_view = new TagView(); lower_hbox.PackStart(tag_view, false, true, 0); Label comment = new Label(Catalog.GetString("Description:")); lower_hbox.PackStart(comment, false, false, 0); description_entry = new Entry(); lower_hbox.PackStart(description_entry, true, true, 0); description_entry.Changed += HandleDescriptionChanged; rating = new RatingEntry { HasFrame = false, AlwaysShowEmptyStars = true }; lower_hbox.PackStart(rating, false, false, 0); rating.Changed += HandleRatingChanged; SetColors(); inner_vbox.PackStart(lower_hbox, false, true, 0); vbox.ShowAll(); Realized += (o, e) => SetColors(); Preferences.SettingChanged += OnPreferencesChanged; }
public StationEditor(DatabaseTrackInfo track) : base() { AccelGroup accel_group = new AccelGroup(); AddAccelGroup(accel_group); Title = String.Empty; SkipTaskbarHint = true; Modal = true; this.track = track; string title = track == null ? Catalog.GetString("Add new radio station") : Catalog.GetString("Edit radio station"); BorderWidth = 6; DefaultResponse = ResponseType.Ok; Modal = true; ContentArea.Spacing = 6; HBox split_box = new HBox(); split_box.Spacing = 12; split_box.BorderWidth = 6; Image image = new Image(); image.IconSize = (int)IconSize.Dialog; image.IconName = "radio"; image.Yalign = 0.0f; image.Show(); VBox main_box = new VBox(); main_box.BorderWidth = 5; main_box.Spacing = 10; Label header = new Label(); header.Markup = String.Format("<big><b>{0}</b></big>", GLib.Markup.EscapeText(title)); header.Xalign = 0.0f; header.Show(); Label message = new Label(); message.Text = Catalog.GetString("Enter the Genre, Title and URL of the radio station you wish to add. A description is optional."); message.Xalign = 0.0f; message.Wrap = true; message.Show(); table = new Table(5, 2, false); table.RowSpacing = 6; table.ColumnSpacing = 6; genre_entry = ComboBoxText.NewWithEntry(); foreach (string genre in ServiceManager.DbConnection.QueryEnumerable <string> ("SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre")) { if (!String.IsNullOrEmpty(genre)) { genre_entry.AppendText(genre); } } if (track != null && !String.IsNullOrEmpty(track.Genre)) { genre_entry.Entry.Text = track.Genre; } AddRow(Catalog.GetString("Station Genre:"), genre_entry); name_entry = AddEntryRow(Catalog.GetString("Station Name:")); stream_entry = AddEntryRow(Catalog.GetString("Stream URL:")); creator_entry = AddEntryRow(Catalog.GetString("Station Creator:")); description_entry = AddEntryRow(Catalog.GetString("Description:")); rating_entry = new RatingEntry(); HBox rating_box = new HBox(); rating_box.PackStart(rating_entry, false, false, 0); AddRow(Catalog.GetString("Rating:"), rating_box); table.ShowAll(); main_box.PackStart(header, false, false, 0); main_box.PackStart(message, false, false, 0); main_box.PackStart(table, false, false, 0); main_box.Show(); split_box.PackStart(image, false, false, 0); split_box.PackStart(main_box, true, true, 0); split_box.Show(); ContentArea.PackStart(split_box, true, true, 0); Button cancel_button = new Button(Stock.Cancel); cancel_button.CanDefault = false; cancel_button.UseStock = true; cancel_button.Show(); AddActionWidget(cancel_button, ResponseType.Close); cancel_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape, 0, Gtk.AccelFlags.Visible); save_button = new Button(Stock.Save); save_button.CanDefault = true; save_button.UseStock = true; save_button.Sensitive = false; save_button.Show(); AddActionWidget(save_button, ResponseType.Ok); save_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return, 0, Gtk.AccelFlags.Visible); name_entry.HasFocus = true; if (track != null) { if (!String.IsNullOrEmpty(track.TrackTitle)) { name_entry.Text = track.TrackTitle; } if (!String.IsNullOrEmpty(track.Uri.AbsoluteUri)) { stream_entry.Text = track.Uri.AbsoluteUri; } if (!String.IsNullOrEmpty(track.Comment)) { description_entry.Text = track.Comment; } if (!String.IsNullOrEmpty(track.ArtistName)) { creator_entry.Text = track.ArtistName; } rating_entry.Value = track.Rating; } error_container = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); error_container.TopPadding = 6; HBox error_box = new HBox(); error_box.Spacing = 4; Image error_image = new Image(); error_image.Stock = Stock.DialogError; error_image.IconSize = (int)IconSize.Menu; error_image.Show(); error = new Label(); error.Xalign = 0.0f; error.Show(); error_box.PackStart(error_image, false, false, 0); error_box.PackStart(error, true, true, 0); error_box.Show(); error_container.Add(error_box); table.Attach(error_container, 0, 2, 6, 7, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0); genre_entry.Entry.Changed += OnFieldsChanged; name_entry.Changed += OnFieldsChanged; stream_entry.Changed += OnFieldsChanged; OnFieldsChanged(this, EventArgs.Empty); }
public async Task <IActionResult> Insert(RatingEntry rating) { await _repository.AddRating(rating); return(CreatedAtAction("GetRatingsGivenByUser", new { userId = rating.UserId }, rating)); }