public HttpResponseMessage AddReview(HttpRequestMessage request, ReviewView review) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; RatingView rating = new RatingView(); rating.bookID = review.bookID; rating.userID = review.userID; rating.ratingScore = review.ratingScore; bool getReview = service.getOneReviewCheck(review.bookID, review.userID); if (getReview) { response = request.CreateResponse(HttpStatusCode.OK, false); unitOfWork.Commit(); return response; } bool getRating = servRat.checkIfRatingExists(review.bookID, review.userID); if (getRating) { response = request.CreateResponse(HttpStatusCode.OK, false); unitOfWork.Commit(); return response; } bool wasAddedReview = service.addReview(review); bool wasAddedRating = servRat.addRating(rating); if (wasAddedReview && wasAddedRating) { response = request.CreateResponse(HttpStatusCode.OK, true); } else { response = request.CreateResponse(HttpStatusCode.InternalServerError); } unitOfWork.Commit(); return response; })); }
/// <summary> /// Evaluate through all conditions in the collection and if all necessary conditions are met open the rating page asynchronously. /// </summary> /// <param name="conditionName">The unique name of the condition that should be prioritized.</param> /// <param name="parameter">An optional parameter that will be passed to the manipulation process for the specified condition.</param> /// <param name="manipulateOnly">Set to true if the specified condition should not be prioritized in the actual evaluation phase and be used for manipulation only. The default is false.</param> /// <remarks> /// Use <see cref="Evaluate(string, object?, bool)"/> if you are not sure about which one to use. /// <para/> /// The evaluation process will first manipulate all conditions that allow implicit manipulation by using their parameterless manipulation method. /// After manipulation, the actual evaluation will happen, and after evaluation has finished all met conditions will be reset which allow automatic reset. /// <para/> /// If the specified condition is not used for manipulation only, it will be prioritized by the evaluator. This means that the prioritized condition must be /// met in addition to all prerequisite and required conditions, before evaluating to true. /// </remarks> public async Task EvaluateAsync(string conditionName, object?parameter = default, bool manipulateOnly = false) { ManipulateConditionState(new Dictionary <string, object?>() { { conditionName, parameter } }); var evaluationResult = EvaluateConditions(manipulateOnly ? null : new List <string>() { conditionName }); if (evaluationResult) { await RatingView.TryOpenRatingPageAsync(); } ResetAllMetConditions(evaluationResult); }
public void HideRatingView() { ratingView.RemoveFromSuperview(); ratingView.Dispose(); ratingView = null; //We have to scroll a little to update the header size. //Using LayoutSubviews(), SetNeedsLayout(), LayoutIfNeeded() etc. does not work. var offset = TimeEntriesLogTableView.ContentOffset; var rect = new CGRect { X = offset.X, Y = offset.Y == 0 ? TimeEntriesLogTableView.Frame.Height + 1 : offset.Y - 1, Width = 1, Height = 1 }; TimeEntriesLogTableView.ScrollRectToVisible(rect, true); }
partial void IncreaseRating(Foundation.NSObject sender) { // Maximum of 5 "stars" if (++Rating > 5) { // Abort Rating = 5; return; } // Create new rating icon and add it to stack var icon = new UIImageView(new UIImage("icon.png")); icon.ContentMode = UIViewContentMode.ScaleAspectFit; RatingView.AddArrangedSubview(icon); // Animate stack UIView.Animate(0.25, () => { // Adjust stack view RatingView.LayoutIfNeeded(); }); }
partial void DecreaseRating(Foundation.NSObject sender) { // Minimum of zero "stars" if (--Rating < 0) { // Abort Rating = 0; return; } // Get the last subview added var icon = RatingView.ArrangedSubviews[RatingView.ArrangedSubviews.Length - 1]; // Remove from stack and screen RatingView.RemoveArrangedSubview(icon); icon.RemoveFromSuperview(); // Animate stack UIView.Animate(0.25, () => { // Adjust stack view RatingView.LayoutIfNeeded(); }); }
public GamesViewModel() { LoginViewModel = new LoginViewModel(); ScoreboardViewModel = new ScoreboardViewModel(); TicTacToeViewModel = new TicTacToeViewModel(); PairGameViewModel = new PairGameViewModel(); RatingViewModel = new RatingViewModel(); SnakeViewModel = new SnakeViewModel(); DoorsGameViewModel = new DoorsGameViewModel(); MoneyViewModel = new MoneyViewModel(); _playerManager = new PlayerManager(); NewGameCommand = new RelayCommand(param => StartGame((string)param)); ShopCommand = new RelayCommand(param => { ShopWindow shopWindow = new ShopWindow(); shopWindow.ShowDialog(); }); ScoreboardCommand = new RelayCommand(param => { ScoreboardViewModel.Refresh(); ScoreboardView scoreboardView = new ScoreboardView(); scoreboardView.ShowDialog(); }); RatingCommand = new RelayCommand(param => { RatingView ratingView = new RatingView(); ratingView.ShowDialog(); }); PlayerEditCommand = new RelayCommand(param => { EditView editView = new EditView(); editView.ShowDialog(); }); AddMoneyCommand = new RelayCommand(param => { MoneyView moneyView = new MoneyView(); moneyView.ShowDialog(); }); StartGameTestingCommand = new RelayCommand(param => { StartGameTesting((string)param); }); BuyItemCommand = new RelayCommand(param => { if (int.Parse(param.ToString()) > Money) { MessageBox.Show("You do not have enough to buy this game.\n Consider adding money to your balance.", "Message", MessageBoxButton.OK); } else { _playerManager.AddMoney(LoginViewModel.Player.Id, -int.Parse(param.ToString())); Money = Money; } }); }
public ActionResult Delete(RatingView ratingView) { DB.RemoveRating(ratingView); //DB.UpdateItemRating(ratingView.ItemId); return(RedirectToAction("Index", "Items")); }
public HttpResponseMessage GetReviewUsers(HttpRequestMessage request, [FromUri] PagingParameterModel pagingparametermodel, [FromUri] string filterAfter, [FromUri] string filterField, [FromUri] string sortMethod, [FromUri] string IDURL) { return(CreateHttpResponse(request, () => { int CurrentPage = pagingparametermodel.pageNumber; int PageSize = pagingparametermodel.pageSize; IEnumerable <Review> reviews = service.getReviewAfterUser(IDURL, CurrentPage, PageSize, filterAfter, filterField, sortMethod); List <ReviewOfUserView> reviewList = new List <ReviewOfUserView>(); foreach (Review b in reviews) { ReviewOfUserView obj = new ReviewOfUserView(); obj.reviewText = b.reviewText; obj.userID = b.userID; obj.bookID = b.bookID; obj.ID = b.ID; obj.ratingScore = 0; obj.addedTime = b.addedTime; UserDataNoPass usr = servUs.getUserAfterID(obj.userID); if (usr != null) { obj.user = usr; } else { obj.user = new UserDataNoPass(); } RatingView rati = servRat.getRating(obj.bookID, obj.userID); if (rati != null) { obj.ratingScore = rati.ratingScore; } else { obj.ratingScore = 0; } Book bookOfRev = b.book; BookViewList bookObj = new BookViewList(); bookObj.title = bookOfRev.title; bookObj.bookPic = bookOfRev.bookPic; bookObj.releaseDate = bookOfRev.releaseDate; bookObj.ID = bookOfRev.ID; List <GenreViewName> genreView = Mapper.Map <List <Genre>, List <GenreViewName> >(bookOfRev.genre.ToList()); List <AuthorViewName> authorView = Mapper.Map <List <Author>, List <AuthorViewName> >(bookOfRev.author.ToList()); double average = 0; if (bookOfRev.rating.Select(x => x.ratingScore).Any()) { average = bookOfRev.rating.Select(x => x.ratingScore).Average(); } bookObj.author = authorView; bookObj.genre = genreView; bookObj.rating = average; obj.book = bookObj; reviewList.Add(obj); } HttpResponseMessage response = null; response = request.CreateResponse(HttpStatusCode.OK, reviewList, JsonMediaTypeFormatter.DefaultMediaType); return response; })); }
public HttpResponseMessage GetReviewPagined(HttpRequestMessage request, [FromUri] PagingParameterModel pagingparametermodel, [FromUri] string filterAfter, [FromUri] string filterField, [FromUri] string sortMethod, [FromUri] string IDURL, [FromUri] string isbn) { return(CreateHttpResponse(request, () => { int CurrentPage = pagingparametermodel.pageNumber; int PageSize = pagingparametermodel.pageSize; BookViewWithISBN bookID = new BookViewWithISBN(); if (IDURL.Equals("null")) { bookID.ID = 0; } else { bookID.ID = Int32.Parse(IDURL); } if (isbn.Equals("null")) { bookID.isbn = "0"; } else { bookID.isbn = isbn; } IEnumerable <Review> reviews = service.getReviewFilteredPaginated(bookID, CurrentPage, PageSize, filterAfter, filterField, sortMethod); List <ReviewView> reviewList = new List <ReviewView>(); foreach (Review b in reviews) { ReviewView obj = new ReviewView(); obj.reviewText = b.reviewText; obj.userID = b.userID; obj.bookID = b.bookID; obj.ID = b.ID; obj.ratingScore = 0; obj.addedTime = b.addedTime; UserDataNoPass usr = servUs.getUserAfterID(obj.userID); if (usr != null) { obj.user = usr; } else { obj.user = new UserDataNoPass(); } RatingView rati = servRat.getRating(obj.bookID, obj.userID); if (rati != null) { obj.ratingScore = rati.ratingScore; } else { obj.ratingScore = 0; } reviewList.Add(obj); } HttpResponseMessage response = null; response = request.CreateResponse(HttpStatusCode.OK, reviewList, JsonMediaTypeFormatter.DefaultMediaType); return response; })); }
public DiscountDetailPage(DiscountDetailData discountDetailData) : base(typeof(DiscountDetailViewModel), typeof(DiscountDetailContentUI)) { BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>(); Content.BackgroundColor = MainStyles.MainLightBackgroundColor.FromResources <Color>(); var loadingColor = MainStyles.LoadingColor.FromResources <Color>(); LoadingActivityIndicator.Color = loadingColor; LoadingActivityText.TextColor = loadingColor; viewModel.SetDiscount(discountDetailData); var mainLayout = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand }; var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack) { BarColor = Color.Transparent, BoxPadding = { BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>() }, BtnBack = { BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>(), Source = contentUI.IconBack } }; #region Label percent const int sizeImgLabel = 60; var imgLabel = new Image { HeightRequest = sizeImgLabel, WidthRequest = sizeImgLabel, Source = contentUI.ImgPercentLabel }; var labelLayout = new AbsoluteLayout { InputTransparent = true }; AbsoluteLayout.SetLayoutFlags(imgLabel, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(imgLabel, new Rectangle(0f, 0f, 1f, 1f)); labelLayout.Children.Add(imgLabel); var spanDiscountPercent = new Span { Style = LabelStyles.LabelPercentStyle.FromResources <Style>() }; spanDiscountPercent.SetBinding(Span.TextProperty, nameof(DiscountDetailViewModel.DiscountPercent)); var spanDiscountType = new Span { Style = LabelStyles.LabelPercentSymbolStyle.FromResources <Style>() }; spanDiscountType.SetBinding(Span.TextProperty, nameof(DiscountDetailViewModel.DiscountType)); var txtPercent = new Label { Rotation = -15, TranslationY = -1, FormattedText = new FormattedString { Spans = { spanDiscountPercent, spanDiscountType } } }; AbsoluteLayout.SetLayoutFlags(txtPercent, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(txtPercent, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); labelLayout.Children.Add(txtPercent); #endregion #region WebAddress & Category list var flexCategories = new FlexLayout { Direction = FlexDirection.Row, Wrap = FlexWrap.Wrap, JustifyContent = FlexJustify.Start, AlignItems = FlexAlignItems.Center, AlignContent = FlexAlignContent.Start, Margin = new Thickness(20, 15, 15, 0) }; const int sizeWebAddress = 40; foreach (var webAddress in viewModel.WebAddresses) { var imgWebAddress = new Image { Source = webAddress.Type.GetWebAddressIcon(), Margin = new Thickness(0, 0, 5, 5), WidthRequest = sizeWebAddress, HeightRequest = sizeWebAddress }; var tapWebAddress = new TapGestureRecognizer { CommandParameter = webAddress.Url }; tapWebAddress.Tapped += viewModel.TxtUrlAddress_Click; imgWebAddress.GestureRecognizers.Add(tapWebAddress); flexCategories.Children.Add(imgWebAddress); } var flexSeparator = new ContentView(); FlexLayout.SetGrow(flexSeparator, 1); flexCategories.Children.Add(flexSeparator); foreach (var category in viewModel.Categories) { var categoryLayout = new CategoryItemTemplate { Margin = new Thickness(0, 0, 5, 5), BindingContext = category }; flexCategories.Children.Add(categoryLayout); } #endregion #region Carousel images var carouselView = new CarouselViewControl { Orientation = CarouselViewOrientation.Horizontal, ItemTemplate = new DataTemplate(typeof(GalleryImageItemTemplate)), CurrentPageIndicatorTintColor = MainStyles.MainBackgroundColor.FromResources <Color>() }; carouselView.SetBinding(CarouselViewControl.ItemsSourceProperty, nameof(DiscountDetailViewModel.GalleryImages)); carouselView.SetBinding(CarouselViewControl.ShowIndicatorsProperty, nameof(DiscountDetailViewModel.HasGalleryImages)); carouselView.SetBinding(CarouselViewControl.IsSwipeEnabledProperty, nameof(DiscountDetailViewModel.HasGalleryImages)); var carouselLayout = new RelativeLayout { VerticalOptions = LayoutOptions.Start }; carouselLayout.Children.Add(carouselView, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width), Constraint.RelativeToParent(parent => Device.Info.CurrentOrientation.IsPortrait() ? parent.Width * 0.5625 : Device.Idiom == TargetIdiom.Phone ? 200 : 400)); carouselLayout.Children.Add(labelLayout, Constraint.RelativeToView(carouselView, (parent, view) => view.Width - sizeImgLabel - 5), Constraint.RelativeToView(carouselView, (parent, view) => view.Height - sizeImgLabel - 5)); #endregion #region Name company var txtPartnerName = new Label { Style = LabelStyles.DetailTitleStyle.FromResources <Style>(), Margin = new Thickness(20, 0) }; txtPartnerName.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.NameCompany)); #endregion #region Description var txtDescription = new Label { Style = LabelStyles.DescriptionStyle.FromResources <Style>(), Margin = new Thickness(20, 10, 20, 0), LineBreakMode = LineBreakMode.WordWrap }; txtDescription.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.Description)); #endregion #region Rating view var ratingView = new RatingView { Style = LabelStyles.RatingStyle.FromResources <Style>() }; ratingView.SetBinding(RatingView.ValueProperty, nameof(DiscountDetailViewModel.UserRating)); var ratingLabel = new Label { Style = LabelStyles.DescriptionStyle.FromResources <Style>(), VerticalOptions = LayoutOptions.End }; ratingLabel.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.RatingString)); ratingLabel.SetBinding(IsVisibleProperty, nameof(DiscountDetailViewModel.IsDiscountRatingAvailable)); var activityIndicator = new ActivityIndicator { Color = Color.FromHex("444"), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, WidthRequest = 20, HeightRequest = 20 }; activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(DiscountDetailViewModel.IsLoadingRating)); activityIndicator.SetBinding(IsVisibleProperty, nameof(DiscountDetailViewModel.IsLoadingRating)); var stackRating = new StackLayout { Orientation = StackOrientation.Horizontal, Margin = new Thickness(20, 0), Spacing = 10, Children = { ratingView, ratingLabel, activityIndicator } }; #endregion var discountLayout = new StackLayout { Spacing = 0, Orientation = StackOrientation.Vertical, Children = { carouselLayout, flexCategories, txtPartnerName, stackRating, txtDescription } }; foreach (var brachItem in viewModel.BranchItems) { var view = new BranchInfoViewTemplate(contentUI, viewModel) { BindingContext = brachItem }; discountLayout.Children.Add(view); } var scrollDiscount = new ScrollView { Content = discountLayout }; AbsoluteLayout.SetLayoutFlags(scrollDiscount, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(scrollDiscount, new Rectangle(0f, 0f, 1f, 1f)); mainLayout.Children.Add(scrollDiscount); AbsoluteLayout.SetLayoutFlags(appBar, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional); AbsoluteLayout.SetLayoutBounds(appBar, new Rectangle(0f, 0f, 1f, AbsoluteLayout.AutoSize)); mainLayout.Children.Add(appBar); var safeAreaHelper = new SafeAreaHelper(); safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top); safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left); safeAreaHelper.UseSafeArea(scrollDiscount, SafeAreaHelper.CustomSafeAreaFlags.Horizontal); ContentLayout.Children.Add(mainLayout); }