public void ActivateFinalDayStars(StarRating rating, float delay) { for (int i = 0; i < endOfDayStars.Count; i++) { finalDayStars[i].ResetStar(); } switch (rating) { case StarRating.ZERO: break; case StarRating.ONE: StartCoroutine(Activate(finalDayStars[0], delayBetweenStars)); break; case StarRating.TWO: StartCoroutine(Activate(finalDayStars[0], delayBetweenStars)); StartCoroutine(Activate(finalDayStars[1], delayBetweenStars)); break; case StarRating.THREE: StartCoroutine(Activate(finalDayStars[0], delayBetweenStars)); StartCoroutine(Activate(finalDayStars[1], delayBetweenStars)); StartCoroutine(Activate(finalDayStars[2], delayBetweenStars * 2)); break; default: break; } }
public async Task VoteAsync(int productId, string userId, int rating) { var starRating = await this.starRatingsRepository .All() .FirstOrDefaultAsync(x => x.ProductId == productId && x.UserId == userId); if (starRating != null) { if (DateTime.UtcNow < starRating.NextVoteDate) { throw new ArgumentException(ExceptionMessages.AlreadySentVote); } starRating.Rate += rating; starRating.NextVoteDate = DateTime.UtcNow.AddDays(1); } else { starRating = new StarRating { ProductId = productId, UserId = userId, Rate = rating, NextVoteDate = DateTime.UtcNow.AddDays(1), }; await this.starRatingsRepository.AddAsync(starRating); } await this.starRatingsRepository.SaveChangesAsync(); }
private void EndGame(float delayTime) { StarRating rating = ratingCalculator.GetStarRating(totalAliveCustomers, totalAliveCustomers + totalDeadCustomers); dayUI.FinalDay(currentDay, descriptionLibrary.GetFinalDayDescription(rating), totalAliveCustomers, totalDeadCustomers); StartCoroutine(ActivateStarRating(rating, delayTime, true)); }
public async Task CheckIfVoteAsyncWorksCorrectlyAfterSecondVoting() { this.SeedDatabase(); var starRating = new StarRating { Rate = 10, MovieId = 1, UserId = this.user.Id, NextVoteDate = DateTime.UtcNow.AddDays(-1), }; await this.starRatingsRepository.AddAsync(starRating); await this.starRatingsRepository.SaveChangesAsync(); await this.ratingsService.VoteAsync(this.firstMovie.Id, this.user.Id, 5); var count = await this.starRatingsRepository.All().CountAsync(); var currentStarRating = await this.starRatingsRepository.All().FirstOrDefaultAsync(); Assert.Equal(1, count); Assert.Equal(15, currentStarRating.Rate); Assert.Equal(starRating.NextVoteDate, currentStarRating.NextVoteDate); }
public ActionResult DeleteConfirmed(int id) { StarRating starrating = db.StarRatings.Find(id); db.StarRatings.Remove(starrating); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { StarRating starRating = await db.StarRating.FindAsync(id); db.StarRating.Remove(starRating); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
void Awake() { resources = new GameObject[7]; //load buildings that can be spawned resources[0] = Resources.Load("Model Prefabs/Palisade") as GameObject; //0 resources[1] = Resources.Load("Model Prefabs/GateHouse") as GameObject; //1 resources[2] = Resources.Load("Model Prefabs/ChiefHall") as GameObject; //2 resources[3] = Resources.Load("Model Prefabs/HuntersHut") as GameObject; //3 resources[4] = Resources.Load("Model Prefabs/WoodcuttersHut") as GameObject; //4 resources[5] = Resources.Load("Farm/Cow") as GameObject; //5 resources[6] = Resources.Load("Farm/Sheep") as GameObject; //6 //load particle effects destroyParticles = Resources.Load("Particle Effects/DestroyParticles") as GameObject; if (wallsLeft == null) { Debug.Log("NULL LEFT"); } if(wallsRight == null) { Debug.Log("NULL RIGHT"); } //get star rating script starManager = GameObject.Find("StarRating").GetComponent<StarRating>(); //GameObject.FindGameObjectWithTag("StarRatingUI").GetComponent<StarRating>(); //load transforms of build tiles positions.AddRange(GameObject.FindGameObjectsWithTag("BuildLocation")); //spawn Gate house SpawnGateHouse(); //spawn Chiefs Hut SpawnChiefHut(); //spawn buildings WorldSpawn(); //lookAt.position = new Vector3(lookAt.position.x, Terrain.activeTerrain.SampleHeight(lookAt.position), lookAt.position.z); foreach(GameObject i in positions) { i.transform.position = new Vector3(i.transform.position.x, Terrain.activeTerrain.SampleHeight(i.transform.position), i.transform.position.z); } starRatingAudioPar_ = MusicManager.musicManager.GetStarRatingParameter(); starRatingAudioPar_.setValue(starRating); }
public async Task <ActionResult> Edit([Bind(Include = "RatingID,RatingImage")] StarRating starRating) { if (ModelState.IsValid) { db.Entry(starRating).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(starRating)); }
private void AddNewRating(HoneypotUser user, int bookId, StarRating starRating) { var rating = new Rating() { Stars = starRating, UserId = user.Id, BookId = bookId }; this.context.Ratings.Add(rating); }
public ActionResult PostRating(int rating, int mid) { StarRating rt = new StarRating(); rt.Rate = rating; rt.CustomerId = mid; _context.Ratings.Add(rt); _context.SaveChanges(); return(Ok()); }
public ActionResult Edit([Bind(Include = "Id,ScenicSpotId,Username,RatingDate,Star")] StarRating starrating) { if (ModelState.IsValid) { db.Entry(starrating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ScenicSpotId = new SelectList(db.ScenicSpots, "ScenicSpotId", "ScenicSpotName", starrating.ScenicSpotId); ViewBag.Username = new SelectList(db.Users, "Username", "Password", starrating.Username); return(View(starrating)); }
public IActionResult Rate(int stars, int bookId) { StarRating starRating = ValidateStars(stars); var book = this.bookService.GetBookById(bookId); if (ModelState.IsValid) { OnPostUserRateBook(bookId, starRating); } return(RedirectToAction("Details", "Book", new { id = book.Id })); }
public async Task <ActionResult> Create([Bind(Include = "RatingID,RatingImage")] StarRating starRating) { if (ModelState.IsValid) { db.StarRating.Add(starRating); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(starRating)); }
/// <summary> /// Initializes a new instance of the <see cref="RatingBoxController"/> class. /// </summary> /// <param name="element">The element representig the related <see cref="RatingBox"/></param> /// <param name="enabled">True if the <see cref="RatingBox"/> is modifiable, false otherwise</param> public RatingBoxController(RatingBox element, bool enabled) : base(enabled) { this.element = element; starRating = new StarRating(element.Values.Length, enabled); starRating.SelectedIndex = element.SelectedIndex - 1; Content = starRating; Title = element.Name; Description = element.Description; }
private IEnumerator ActivateStarRating(StarRating rating, float delay, bool finalDay = false) { yield return(new WaitForEndOfFrame()); if (finalDay) { starRatingUI.ActivateFinalDayStars(rating, delay); } else { starRatingUI.ActivateEndOfDayStars(rating, delay); } }
// GET: StarRatings/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StarRating starRating = await db.StarRating.FindAsync(id); if (starRating == null) { return(HttpNotFound()); } return(View(starRating)); }
// GET: /StarRating/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StarRating starrating = db.StarRatings.Find(id); if (starrating == null) { return(HttpNotFound()); } return(View(starrating)); }
public ActionResult New(string id) { ApplicationUser Receiver = db.Users.Find(id); string ReceiverId = Receiver.Id; string GiverId = User.Identity.GetUserId(); StarRating rating = new StarRating(); rating.ReceiverId = ReceiverId; ViewBag.ReceiverName = Receiver.UserName; rating.GiverId = GiverId; rating.Values = GetAllValues(); rating.StarRatingId = CountRatings().ToString(); return(View(rating)); }
private void InitializeFields() { this.firstShoppingCart = new ShoppingCart { UserId = "1", }; this.user = new PhotoPavilionUser { Id = "1", Gender = Gender.Male, UserName = "******", FullName = "Pesho Peshov", Email = "*****@*****.**", PasswordHash = "123456", ShoppingCartId = 1, }; this.firstBrand = new Brand { Name = "Canon", }; this.firstCategory = new Category { Name = "Cameras", Description = "Sample category description", }; this.firstProduct = new Product { Id = 1, Name = "Canon eos 1100D", Code = 10600, Description = "Sample description for Canon eos 1100D", Price = 1500, ImagePath = "test image path", BrandId = 1, CategoryId = 1, }; this.firstStarRating = new StarRating { Rate = 5, ProductId = 1, UserId = this.user.Id, NextVoteDate = DateTime.UtcNow.AddDays(1), }; }
private void OnPostUserRateBook(int bookId, StarRating starRating) { var user = this.usersService.GetByUsername(this.User.Identity.Name); var userHasRatedBook = this.ratingService.HasUserRatedBook(user.Id, bookId); if (userHasRatedBook) { ChangeRating(user, bookId, starRating); } else { AddNewRating(user, bookId, starRating); } this.context.SaveChanges(); }
// GET: /StarRating/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StarRating starrating = db.StarRatings.Find(id); if (starrating == null) { return(HttpNotFound()); } ViewBag.ScenicSpotId = new SelectList(db.ScenicSpots, "ScenicSpotId", "ScenicSpotName", starrating.ScenicSpotId); ViewBag.Username = new SelectList(db.Users, "Username", "Password", starrating.Username); return(View(starrating)); }
public string GetFinalDayDescription(StarRating rating) { if (endOfDayDescriptions.Count <= 0) { return(string.Empty); } List <Description> descriptionRating = finalDayDescriptions.FindAll(d => d.Rating == rating); if (descriptionRating.Count <= 0) { return(string.Empty); } return(descriptionRating[Random.Range(0, descriptionRating.Count)].DescriptionText); }
public void EndDay(float delayTime) { dayEnded = true; totalAliveCustomers += aliveCustomers; totalDeadCustomers += deadCustomers; if (currentDay >= totalDays) { EndGame(delayTime); return; } StarRating rating = ratingCalculator.GetStarRating(aliveCustomers, customersPerDay); dayUI.EndDay(currentDay, descriptionLibrary.GetEndOfDayDescription(rating), 100, aliveCustomers, deadCustomers); StartCoroutine(ActivateStarRating(rating, delayTime)); }
public static double GetStarRatingAsDouble(StarRating s) { switch (s) { case StarRating.One: return(1.0); case StarRating.Two: return(2.0); case StarRating.Three: return(3.0); case StarRating.Four: return(4.0); case StarRating.Five: return(5.0); default: return(0.0); } }
public JsonResult PostRating(int rating, int mid) { //save data into the database StarRating rt = new StarRating(); string ip = Request.ServerVariables["REMOTE_ADDR"]; rt.Rate = rating; rt.IpAddress = ip; rt.MovieId = mid; //save into the database dbcontext.StarRatings.Add(rt); dbcontext.SaveChanges(); return(Json("You rated this " + rating.ToString() + " star(s)")); }
private void InitializeFields() { this.user = new CinemaWorldUser { Id = "1", Gender = Gender.Male, UserName = "******", FullName = "Pesho Peshov", Email = "*****@*****.**", PasswordHash = "123456", }; this.firstDirector = new Director { FirstName = "Peter", LastName = "Kirilov", }; this.firstMovie = new Movie { Name = "Titanic", DateOfRelease = DateTime.UtcNow, Resolution = "HD", Rating = 7.80m, Description = "Test description here", Language = "English", CinemaCategory = CinemaCategory.B, TrailerPath = "test trailer path", CoverPath = "test cover path", WallpaperPath = "test wallpaper path", IMDBLink = "test imdb link", Length = 120, DirectorId = 1, }; this.firstStarRating = new StarRating { Rate = 5, MovieId = 1, UserId = this.user.Id, NextVoteDate = DateTime.UtcNow.AddDays(1), }; }
public static List <StarRating> getStars(HtmlDocument doc) { var starCollection = doc.DocumentNode.SelectNodes("//div[@class='sc-product-card-stars']"); List <StarRating> starsCollection = new List <StarRating>(); foreach (HtmlNode item in starCollection) { var htmlTitle = new HtmlDocument(); htmlTitle.LoadHtml(item.InnerHtml); var avg = htmlTitle.DocumentNode.SelectNodes("//span[@class='seo-avg-rating']").FirstOrDefault(); var best = htmlTitle.DocumentNode.SelectNodes("//span[@class='seo-best-rating']").FirstOrDefault(); var reviews = htmlTitle.DocumentNode.SelectNodes("//span[@class='seo-review-count']").FirstOrDefault(); var rating = new StarRating(); rating.seo_avg_rating = avg.InnerText; rating.seo_best_rating = best.InnerText; rating.seo_review_count = reviews.InnerText; starsCollection.Add(rating); } return(starsCollection); }
public async Task <ActionResult> RateJob(PostJob model) { var post = postJobRepository.GetPostJobById(model.Id); var userID = User.Identity.GetUserId(); if (post == null) { return(HttpNotFound()); } StarRating rating = new StarRating(); PostJob postfromDb = new PostJob(); var IsRatingBefore = await _db.Stars.FirstOrDefaultAsync(r => r.PostId == model.Id && r.UserId == userID); if (IsRatingBefore != null) { ViewBag.AlreadyRatedMessage = "You have already Rate this job"; } else { rating.PostId = model.Id; rating.UserId = userID; rating.Rating = model.Rate; postfromDb = _db.PostJobs.Find(model.Id); postfromDb.Rate = (postfromDb.Rate + rating.Rating) / 2; _db.Stars.Add(rating); _db.Entry(postfromDb).State = EntityState.Modified; await _db.SaveChangesAsync(); return(RedirectToAction("Index", "Posts", new { area = "" })); } return(View(post)); }
public ActionResult New(StarRating rating) { rating.Values = GetAllValues(); try { if (ModelState.IsValid) { db.StarRatings.Add(rating); db.SaveChanges(); return(RedirectToAction("OnPressUser", "Users", new { id = rating.ReceiverId })); } else { TempData["Message"] = "Failed to create new rating"; return(View(rating)); } } catch (Exception e) { return(View(rating)); } }
public ActionResult OnPressStar(int id, int stars) { System.Diagnostics.Debug.WriteLine("id" + id + "stele : " + stars); //verifica daca produsul are deja review de la user Product product = db.Products.Find(id); StarRating review = new StarRating(); var reviews = from rev in db.Ratings where rev.ProductId == id && rev.UserId == product.UserId select rev; var check = 0; foreach (StarRating rev in reviews) { check++; review = rev; } if (check == 0)// nu exista review de la user si trb creat { System.Diagnostics.Debug.WriteLine("nu exista"); review.ProductId = product.ProductId; review.UserId = product.UserId; review.Rate = stars; db.Ratings.Add(review); db.SaveChanges(); } else//exista review si trb modificat { System.Diagnostics.Debug.WriteLine(" exista"); review.Rate = stars; db.SaveChanges(); } return(RedirectToAction("Show", "Product", new { id = product.ProductId })); }
public void CreateNewRssFile() { var myFeed = new MediaRssFeed { Copyright = new TextSyndicationContent("Copyright 2010-2020 @ Because it looks good"), Description = new TextSyndicationContent("This is a sample media feed"), Title = new TextSyndicationContent("Hello Media Feed World!") }; var feedItems = new List<MediaRssItem>(); var item = new MediaRssItem(); var rating = new StarRating {Min = 1, Max = 5}; item.OptionalElements.CommunityNode = new Community { Rating = rating}; feedItems.Add(item); myFeed.Items = feedItems; var settings = new XmlWriterSettings { NewLineOnAttributes = true, NamespaceHandling = NamespaceHandling.OmitDuplicates, CloseOutput = true, Indent = true }; using (var writer = XmlWriter.Create("TestOutput.rss", settings)) { var formatter = new MediaRssFeedFormatter(myFeed); formatter.WriteTo(writer); } }
public void RateService(StarRating rating) { // do something with the rating here. }