public async Task <ActionResult> AddReview(AddReviewViewModel model)
        {
            try
            {
                if (model != null)
                {
                    using (ExploreDbContext context = new ExploreDbContext())
                    {
                        // Add the review to database
                        ReviewModel newReview = new ReviewModel();
                        newReview.createddate   = DateTime.Now;
                        newReview.dislikes      = 0; newReview.likes = 0;
                        newReview.overallrating = model.rating;
                        newReview.id            = Convert.ToString(Guid.NewGuid());
                        newReview.reviewmessage = model.review;
                        newReview.PositionId    = model.id;
                        newReview.UserId        = User.Identity.GetUserId();

                        context.AddReviewModel(newReview);
                        await context.SaveChangesAsync();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(RedirectToActionPermanent("Index", new { id = model.id })
                   );
        }
Example #2
0
        public IActionResult create(AddReviewViewModel model)  //we must pass in the model or object here and give it a name. We are accepting a addreviewviewmodel and calling it model
        {
            Review NewReview = new Review
            {
                Reviewer_Name   = model.Reviewer_Name,
                Restaurant_Name = model.Restaurant_Name,
                Description     = model.Description,
                Date            = model.Date,
                Stars           = model.Stars
            };

            if (TryValidateModel(NewReview))
            {
                _context.reviews.Add(NewReview);
                _context.SaveChanges();
                return(View("Success"));
            }
            else
            {
                ViewBag.errors = ModelState.Values;
                System.Console.WriteLine("=============================");
                System.Console.WriteLine(ViewBag.errors);
                System.Console.WriteLine("=============================");
            }
            return(View("Index"));
        }
        public IActionResult Index(AddReviewViewModel model)
        {
            if (model == null)
            {
            }
            var reviewstar = _context.starRatings.
                             FirstOrDefault(p => p.StarRatingId == model.ReviewId);
            RoomReview review = new RoomReview()
            {
                ReviewStar = reviewstar.StarNo,
                Review     = model.Review,
                UserName   = model.UserName,
                hotelRoom  = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId
                                                                == model.RoomId)
            };

            _context.Add(review);

            if (_context.SaveChanges() > 0)
            {
                return(RedirectToAction("Index", new
                {
                    area = "User",
                    controller = "RoomReview",
                    id = model.RoomId
                }));
            }

            return(View());
        }
Example #4
0
        public ActionResult AddReview(AddReviewViewModel addReviewModel)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(500));
            }

            bool result = false;

            var newReview = new Review();

            newReview.UserId     = addReviewModel.UserId;
            newReview.Body       = addReviewModel.Body;
            newReview.ReviewedAt = DateTime.Now;
            newReview.Rate       = addReviewModel.Rate;
            newReview.ProductId  = addReviewModel.ProductId;

            result = ReviewService.Instance.SaveReview(newReview);

            if (result)
            {
                return(RedirectToAction("_Reviews", new { productId = newReview.ProductId }));
            }

            return(new HttpStatusCodeResult(500));
        }
        public IActionResult Index(int id)
        {
            AddReviewViewModel        model = null;
            List <AddReviewViewModel> List  = new List <AddReviewViewModel>();

            if (id == null)
            {
            }

            var reviews = _context.hotelReviews.Include(p => p.hotel)

                          .Where(p => p.hotel.HotelId == id).ToList();

            if (reviews == null)
            {
            }

            foreach (var rev in reviews)
            {
                model = new AddReviewViewModel()
                {
                    UserName   = rev.UserName,
                    Review     = rev.Review,
                    ReviewStar = rev.ReviewStar,
                    HotelId    = rev.hotel.HotelId
                };

                List.Add(model);
            }


            return(View(List));
        }
        public async Task <IActionResult> AddReview(AddReviewViewModel addReviewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(addReviewModel));
            }

            var user = await _userManager.FindByNameAsync(addReviewModel.ReviewedBy);

            if (user != null)
            {
                TeaReview review = new TeaReview
                {
                    ReviewedBy  = addReviewModel.ReviewedBy,
                    TeaId       = addReviewModel.TeaId,
                    ReviewedOn  = DateTime.Now,
                    ReviewTitle = addReviewModel.ReviewTitle,
                    ReviewText  = addReviewModel.ReviewText
                };
                var result = _reviewRepository.AddReview(review);

                if (result)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            ModelState.AddModelError("", "User not found can't create review");
            return(View(addReviewModel));
        }
        public async Task <IActionResult> Review(string Isbn)
        {
            var reviewDTO = new AddReviewViewModel {
                Isbn = Isbn
            };

            return(View(reviewDTO));
        }
        public IActionResult Create(int id)
        {
            var model = new AddReviewViewModel {
                ArticleId = id
            };

            return(View(model));
        }
Example #9
0
        public IActionResult AddReview([FromForm] AddReviewViewModel model)
        {
            var userEmail = userManager.GetUserName(User);
            var user      = userService.GetUserByUserEmail(userEmail);

            reviewService.AddReview(model.bookName, model.authorName, model.text, model.Title, user);
            return(View("DashboardView", "Dashboard"));
        }
Example #10
0
        public IActionResult AddReview([FromForm] AddReviewViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            clientsService.AddReview(model.Rating, model.Title, model.Text);
            return(Redirect(Url.Action("Index", "Clients")));
        }
 public AddNewReviewPage(int albumId)
 {
     InitializeComponent();
     BindingContext = vm = new AddReviewViewModel();
     vm.ThisAlbumId = albumId;
     vm.InitCommand.Execute(null);
     vm.PopHandler += (object s, EventArgs r) =>
     {
         Navigation.PopAsync();
     };
 }
Example #12
0
        public async Task <IActionResult> Add(AddReviewViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                await this._reviewsService.AddReview(viewModel);

                return(this.RedirectToAction("Movie", "Reviews", new { id = viewModel.MovieId }));
            }

            return(await this.Movie(viewModel.MovieId));
        }
Example #13
0
        public async Task AddReview(AddReviewViewModel viewModel)
        {
            var user = await this._dbContext.Users.FirstOrDefaultAsync(x => x.Id == viewModel.UserId);

            var name  = user.FirstName + user.LastName;
            var email = user.Email.Substring(0, user.Email.IndexOf("@"));

            name = string.IsNullOrWhiteSpace(name) ? email : name;

            var review = this._mapper.Map <AddReviewViewModel, Review>(viewModel);

            review.AddedBy   = name;
            review.DateAdded = DateTime.UtcNow;
            await this._dbContext.Reviews.AddAsync(review);

            await this._dbContext.SaveChangesAsync();
        }
Example #14
0
        public async Task <IActionResult> AddReview([FromBody] AddReviewViewModel model)
        {
            try
            {
                var userId    = User.GetName();
                var newReview = _mapper.Map <Review>(model);
                newReview.IdSource = int.Parse(userId);
                newReview.Time     = DateTime.Now;
                await _reviewRepository.AddReview(newReview);
            }
            catch (RepositoryException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }

            return(Ok());
        }
        public IActionResult Post([FromForm] AddReviewViewModel model)
        {
            if (!ModelState.IsValid)
            {
            }

            var Review = new ParkingReview()
            {
                Username        = model.Name,
                Review          = model.Review,
                ReviewDate      = DateTime.Now,
                ReviewInNumbers = model.ReviewNo,
                Parking         = _context.parkings.FirstOrDefault(p => p.Name == model.Parking)
            };

            _context.Add(Review);
            _context.SaveChanges();
            return(Ok());
        }
Example #16
0
        public IActionResult Index(int id)
        {
            var Ratings = _context.starRatings;

            if (id == null)
            {
            }

            AddReviewViewModel model = new AddReviewViewModel();

            model.Ratings = Ratings.Select(p => new SelectListItem()
            {
                Text  = p.StarName,
                Value = p.StarRatingId.ToString()
            }).ToList();

            model.HotelId = id;
            return(View(model));
        }
Example #17
0
        public IActionResult AddReview(AddReviewViewModel addReviewViewModel)
        {
            var activeUser = _userManager.GetUserAsync(User).Result;
            var product    = _dbContext.Products.Include(prod => prod.Reviews).FirstOrDefault(prod => prod.Id == addReviewViewModel.ProductId);

            if (product != null)
            {
                var newReview = new Review()
                {
                    Product = product,
                    Rating  = addReviewViewModel.Rating,
                    Text    = addReviewViewModel.Text,
                    User    = activeUser
                };

                _dbContext.Reviews.Add(newReview);
                _dbContext.SaveChanges();
            }

            return(Redirect(Request.Headers["Referer"].ToString()));
        }
Example #18
0
        public IActionResult Add(AddReviewViewModel addReviewViewModel)
        {
            if(ModelState.IsValid)
            {
                Game newGame = context.Games.Single(g => g.ID == addReviewViewModel.GameID);

                ReviewGame newReview = new ReviewGame
                {
                    Review = addReviewViewModel.Review,
                    Rating = addReviewViewModel.Rating,
                    Game = newGame
                };

                context.Reviews.Add(newReview);
                context.SaveChanges();

                return Redirect("/Review");
            }

            return View(addReviewViewModel);
        }
        public IActionResult Add(AddReviewViewModel addReviewViewModel)
        {
            if (ModelState.IsValid)
            {
                Review newReview = new Review
                {
                    Title        = addReviewViewModel.Title,
                    BookReview   = addReviewViewModel.BookReview,
                    GenreName    = addReviewViewModel.GenreName,
                    RatingNumber = addReviewViewModel.RatingNumber,
                    UserName     = User.Identity.Name,
                };


                context.Reviews.Add(newReview);
                context.SaveChanges();


                return(Redirect("/Review"));
            }
            return(View(addReviewViewModel));
        }
Example #20
0
        public ActionResult AddReview(AddReviewViewModel addReviewViewModel)
        {
            Review newReview = new Review
            {
                ReviewBody   = addReviewViewModel.NewReview,
                ReviewByUser = addReviewViewModel.ReviewAuthor,
                Rating       = addReviewViewModel.Rating
            };

            context.Reviews.Add(newReview);
            context.SaveChanges();
            User getUser = context.Users.Single(u => u.Email == (HttpContext.Session.GetString("_Email")));

            getUser.ReviewsMade += 1;
            context.SaveChanges();

            IList <RouteReview> existingItems = context.RouteReviews
                                                .Where(rr => rr.ReviewID == newReview.ID)
                                                .Where(rr => rr.RouteID == addReviewViewModel.RouteId).ToList();

            if (existingItems.Count == 0)
            {
                //var userID = saveFavoriteRouteViewModel.UserID;
                //var routeID = saveFavoriteRouteViewModel.RouteID;
                RouteReview routeReview = new RouteReview
                {
                    Review = context.Reviews.Single(r => r.ID == newReview.ID),/// May not work if not in database yet!!!!*************************************
                    Route  = context.Routes.Single(r => r.ID == addReviewViewModel.RouteId)
                };
                context.RouteReviews.Add(routeReview);
                context.SaveChanges();
                TempData["Alert"] = "New Review has been posted!";
            }


            return(Redirect(string.Format("/Route/DisplaySelectRoute?id={0}", addReviewViewModel.RouteId)));
        }
        public async Task <IActionResult> Create(AddReviewViewModel model)
        {
            if (ModelState.IsValid)
            {
                var article = await _appContext.Articles.SingleOrDefaultAsync(r => r.Id == model.ArticleId);

                Review review = new Review {
                    ArticleId = model.ArticleId, Rating = model.Rating, Decsription = model.Description, Author = model.Author
                };

                _appContext.Reviews.Add(review);
                await _appContext.SaveChangesAsync();

                var reviews = _appContext.Reviews.Where(r => r.ArticleId == article.Id).ToList();

                article.Rating = reviews.Sum(r => r.Rating) / reviews.Count;

                _appContext.Update(article);
                await _appContext.SaveChangesAsync();

                return(RedirectToAction("ArticleProfile", "Articles", new { id = article.Id }));
            }
            return(View(model));
        }
        public async Task <IActionResult> Review(AddReviewViewModel review)
        {
            if (ModelState.IsValid)
            {
                var User = await _userManager.GetUserAsync(HttpContext.User);

                var NewReview = new Review
                {
                    Comment = review.Comment,
                    Rating  = review.Rating,
                    Id      = User.Id,
                    Isbn    = review.Isbn
                              //,Book = Repo.GetBook(review.Isbn)
                };
                await Repo.AddReview(NewReview);

                var Url = "/Home/BookDetails?Isbn=" + review.Isbn;
                return(Redirect(Url));
            }
            else
            {
                return(View("Review", review));
            }
        }
Example #23
0
 public AddReview(int currentMovieId)
 {
     InitializeComponent();
     DataContext = new AddReviewViewModel(this, currentMovieId);
 }
Example #24
0
 public AddReviewView(AddReviewViewModel viewModel)
     : base(viewModel, DataWindowMode.Custom)
 {
     InitializeComponent();
 }
        public async Task <IActionResult> AddReview(AddReviewViewModel model)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var existingReview = _reviewRepository.GetReview(model.Id);

            if (user.Id != existingReview.CriticId)
            {
                StatusMessage = "Error. You cannot review this file.";
                return(RedirectToAction(nameof(MyReviews)));
            }
            if (existingReview.FileName != null)
            {
                StatusMessage = "Error. You can review this paper only once.";
                return(RedirectToAction(nameof(MyReviews)));
            }
            if (model.File == null || model.File.Length == 0)
            {
                StatusMessage = "Error. File is missing or broken.";
                return(View(model));
            }
            if (!model.File.FileName.EndsWith(".doc") && !model.File.FileName.EndsWith(".docx") && !model.File.FileName.EndsWith(".pdf") && !model.File.FileName.EndsWith(".odt"))
            {
                StatusMessage = "Error. File has forbidden extension.(Only .doc .docx .pdf .odt allowed)";
                return(RedirectToAction("AddReview", new { id = model.Id }));
            }
            if (ModelState.IsValid)
            {
                string newFileName = Guid.NewGuid().ToString() + model.File.FileName.Substring(model.File.FileName.Length - 4);
                var    path        = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot\\Reviews",
                    newFileName);

                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await model.File.CopyToAsync(stream);
                }

                var review = Mapper.Map <ReviewDTO>(model);
                review.OriginalFileName = model.File.FileName.Split('\\').Last();
                review.FileName         = newFileName;
                review.CompletionDate   = DateTime.Now;


                var result = _reviewRepository.AddReview(review);

                if (result == 1)
                {
                    var reviews = _reviewRepository.GetPaperVersionReviews(existingReview.PaperVersionId);
                    if (reviews.Where(r => r.Recommendation == 2).Count() >= 2)
                    {
                        _paperVersionRepository.SetStatusVersionAccepted(existingReview.PaperVersionId);
                        _paperRepository.SetStatuAccepted(existingReview.PaperVersion.PaperId);
                    }
                    else if (reviews.Where(r => r.Recommendation == 5).Count() >= 2)
                    {
                        _paperVersionRepository.SetStatusVersionRejected(existingReview.PaperVersionId);
                        _paperRepository.SetStatusDiscarded(existingReview.PaperVersion.PaperId);
                    }
                    else if (reviews.Where(r => r.Recommendation == 3).Count() >= 2)
                    {
                        _paperVersionRepository.SetStatusMinorRevision(existingReview.PaperVersionId);
                    }
                    else if (reviews.Where(r => r.Recommendation == 4).Count() >= 2)
                    {
                        _paperVersionRepository.SetStatusMajorRevision(existingReview.PaperVersionId);
                    }
                    else if (reviews.Where(r => r.Recommendation == 3).Count() >= 1 && reviews.Where(r => r.Recommendation == 2).Count() >= 1)
                    {
                        _paperVersionRepository.SetStatusMinorRevision(existingReview.PaperVersionId);
                    }
                    else if (reviews.Where(r => r.Recommendation == 4).Count() >= 1 && (reviews.Where(r => r.Recommendation == 2 || r.Recommendation == 3).Count() >= 1))
                    {
                        _paperVersionRepository.SetStatusMajorRevision(existingReview.PaperVersionId);
                    }
                    else if (reviews.Where(r => r.Recommendation > 1).Count() == 2 && reviews.Where(r => r.Recommendation == 5).Count() == 1)
                    {
                        //wysłac info do admina o wyborze kolejnego
                    }

                    StatusMessage = "Succesfully added.";
                    return(RedirectToAction(nameof(MyReviews)));
                }

                StatusMessage = "Error. If you see this error. Contact with administrator.";
                return(RedirectToAction(nameof(MyReviews)));
            }
            StatusMessage = "Error. Entered data is not valid.";
            return(View(model));
        }
        public IActionResult Add()
        {
            AddReviewViewModel addReviewViewModel = new AddReviewViewModel();

            return(View(addReviewViewModel));
        }
Example #27
0
 public AddReviewPage(string sellerName)
 {
     BindingContext = reviewView = new AddReviewViewModel(sellerName);
     InitializeComponent();
     _label.Text += sellerName;
 }
Example #28
0
 public IActionResult Add()
 {
     IEnumerable<Game> games = context.Games.ToList();
     AddReviewViewModel addReviewViewModel = new AddReviewViewModel(games);
     return View(addReviewViewModel);
 }