Ejemplo n.º 1
0
        public IActionResult AddRating(int rating, int restaurantId)
        {
            var userId = Convert.ToInt32(HttpContext.User.FindFirstValue("Id"));

            _ratingService.AddRating(rating, userId, restaurantId);

            return(RedirectToAction("Details", new { id = restaurantId }));
        }
Ejemplo n.º 2
0
        public IActionResult Rate(int entityId, int ratingValue, string ratingText)
        {
            _ratingService.AddRating(entityId, _authService.GetCurrentUser().Id, ratingValue, ratingText);
            ModelState.Clear();

            return(Index());
            // update view component ?
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddRating(AddRatingDTO addRatingDto)
        {
            var email = GetEmailFromHttpContextAsync();
            await _ratingService.AddRating(addRatingDto, email);

            _logger.LogInfo($"Add rating by user with email: {email}.");

            return(Ok());
        }
Ejemplo n.º 4
0
        public IActionResult PostRating(RatingRequest rating)
        {
            var userId = User.Claims.First(x => x.Type == "userId").Value;

            rating.UserId = Guid.Parse(userId);
            var result = ratingService.AddRating(rating);

            return(Ok(result));
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> AddRating(NewRatingModel model)
        {
            var result = await service.AddRating(model);

            if (result == null)
            {
                return(BadRequest("Bad request"));
            }

            return(Ok(result));
        }
Ejemplo n.º 6
0
        public ActionResult Rating(Rating rating, int OrderDetailID)
        {
            Member member = Session["Member"] as Member;

            rating.memberID = member.id;
            _ratingService.AddRating(rating);
            _orderDetailService.SetIsRating(OrderDetailID);
            string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~");

            return(Redirect(urlBase));
        }
Ejemplo n.º 7
0
        public IActionResult AddRating(RatingModel model)
        {
            string giverId    = userManager.GetUserId(User);
            string receiverId = model.ReceiverId;
            int    score      = model.Rating;
            int    eventId    = model.EventId;

            ratingService.AddRating(eventId, giverId, receiverId, score, DateTime.Now);

            return(RedirectToAction("DetermineEventView", "HomePage", new { Id = eventId }));
        }
Ejemplo n.º 8
0
 public IActionResult AddRating(int apartmentId, int ratingValue)
 {
     try
     {
         var avgRating = _ratingService.AddRating(ratingValue, apartmentId);
         return(Json(new { success = true, avgRating = avgRating }));
     }
     catch (Exception ex)
     {
         _log.LogError(ex, ex.Message);
         return(Json(new { success = false, avgRating = 0 }));
     }
 }
Ejemplo n.º 9
0
        public IHttpActionResult AddRating(AddRatingViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Model State"));
            }

            var rating = _mapper.Map <Rating>(viewModel);

            _ratingService.AddRating(rating);

            return(Ok());
        }
Ejemplo n.º 10
0
        public IActionResult AddRating([FromBody] RatingViewModel ratingViewModel)
        {
            var rating = _mapper.Map <RatingViewModel, RatingModel>(ratingViewModel);

            rating.UserId = Convert.ToInt32(HttpContext.GetUserIdByHttpContext());

            var ratingResult = _ratingService.AddRating(rating);

            if (ratingResult.Errors != null)
            {
                return(BadRequest(ratingResult.Errors));
            }

            return(Ok());
        }
Ejemplo n.º 11
0
        private void RatingAdding(string name)
        {
            Console.WriteLine("Leave you Rate here(from 0 to 5)(if u dont want rate type n): ");
            string ratingInput = ReadInput();

            if (ratingInput.Equals("n"))
            {
                return;
            }
            int rate = int.Parse(ratingInput);

            ratingService.AddRating(new Rating {
                Name = name, Mark = rate, TimeOfRating = DateTime.Now
            });
        }
Ejemplo n.º 12
0
        public async Task AddRating([GameCode] string gameCode, RatingCreateRequest request)
        {
            int.TryParse(Context.Items[KeyConstants.GameCode] as string, out int gameId);
            if (int.TryParse(Context.UserIdentifier, out int userId) && userId != 0)
            {
                request.PlayerProfileId = await _profileService.GetProfileIdByUserGame(userId, gameId);
            }

            await _ratingService.AddRating(request);

            var(ratingsCount, expectedRatingsCount) =
                await _gameService.GetVotingStatus(gameId, request.ItemId);

            await Clients.Group(gameCode).RefreshVotingProgress(ratingsCount, expectedRatingsCount);
        }
Ejemplo n.º 13
0
        public void TestClearRatings()
        {
            service.AddRating(new Rating {
                Name = "letv", Mark = 5, TimeOfRating = DateTime.Now
            });

            service.ClearRatings();

            Assert.AreEqual <int>(0, service.GetLastRatings().Count);
        }
Ejemplo n.º 14
0
        public IActionResult addUserData([FromForm] string name, [FromForm] string comment, [FromForm] int rating)
        {
            var field = (Field)HttpContext.Session.GetObject("field");

            _scoreService.AddScore(new Score {
                Name = name, Points = field.Score, TimeOfScore = DateTime.Now
            });
            _commentService.AddComment(new Comment {
                Name = name, Message = comment, TimeOFComment = DateTime.Now
            });
            _ratingService.AddRating(new Rating {
                Name = name, Mark = rating, TimeOfRating = DateTime.Now
            });

            return(RedirectToAction("Index", model));
        }
Ejemplo n.º 15
0
        public ActionResult <Rating> AddNewRate(Rating newRating)
        {
            var client = clientService.GetClientById(newRating.IdClient);

            if (client == null)
            {
                return(NotFound());
            }

            var deliveryMan = deliveryMenService.GetDeliveryManById(newRating.IdDeliveryMan);

            if (deliveryMan == null)
            {
                return(NotFound());
            }

            var rating = ratingService.AddRating(newRating);

            return(Ok(rating));
        }
Ejemplo n.º 16
0
        public ActionResult Rate(FormCollection data)
        {
            var rating = new Rating
            {
                MovieId       = new Guid(data["id"]),
                UserId        = User.Identity.GetUserId(),
                ValueOfRating = Convert.ToDouble(data["rate"])
            };
            var movie = _movieService.GetMovieById(new Guid(data["id"]));

            if (movie.Ratings.Count(m => m.MovieId == movie.Id &&
                                    m.UserId == User.Identity.GetUserId()) == 0)
            {
                _ratingService.AddRating(rating);
            }
            _ratingService.Edit(rating);
            var s = _ratingService.CountRatingByMovieId(rating.MovieId);

            ViewBag.Rating = s;
            return(PartialView());
        }
        public async Task <IActionResult> AddRating([FromBody] AddRatingRequest addRatingRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var ipAddress = Request?.HttpContext?.Connection?.RemoteIpAddress?.ToString();

            var ratingResult = await _ratingService.AddRating(addRatingRequest.DeviceId, ipAddress, addRatingRequest.PageId, addRatingRequest.Score);

            if (!ratingResult.Success)
            {
                return(BadRequest(ratingResult.Errors));
            }

            var ratingId = ((Result <Guid>)ratingResult).Data;

            return(Ok(new AddRatingResponse()
            {
                RatingId = ratingId
            }));
        }
        public async Task <IActionResult> GiveRate(Rate rate)
        {
            await ratingService.AddRating(rate);

            return(Redirect("/"));
        }
Ejemplo n.º 19
0
 public void Post([FromBody] Rating rating)
 {
     _ratingService.AddRating(rating);
 }