Example #1
0
        public ActionResult Create([Bind(Include = "ReviewID,Title,Genre,Description,Score,DeveloperID,GameID")] Review review)
        {
            bool Banned = false;

            foreach (Blacklist blacklist in dbBlacklist.Blacklists.ToList())
            {
                if (blacklist.BlacklistIP == Request.UserHostAddress)
                {
                    Banned = true;
                }
            }

            if (ModelState.IsValid && Banned == false)
            {
                review.GameID      = Convert.ToInt32(TempData["GameID"]);
                review.DeveloperID = Convert.ToInt32(TempData["DeveloperID"]);
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            if (Banned == true)
            {
                return(RedirectToAction("../Blacklists/UserBlacklist/"));
            }
            else
            {
                return(View(review));
            }
        }
        public IHttpActionResult PutReview(int id, Review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != review.ReviewId)
            {
                return(BadRequest());
            }

            db.Entry(review).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReviewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public Either <string, CompanyView> Add(CompanyView companyView)
        {
            try
            {
                var companyExists = _dbContext.Companies.Exists(company => company.Name.Equals(companyView.Name));

                if (companyExists)
                {
                    return("company already exists");
                }

                var model = CompanyMapper.ToModel(companyView);
                var view  = companyView;

                _dbContext.Companies.Add(model);
                _dbContext.SaveChanges();

                view.Id = model.Id;

                return(view);
            }
            catch (Exception ex)
            {
                _logger.LogError("can't add company: {0} - ", companyView.Name, ex);
                return(string.Format("can't add company"));
            }
        }
Example #4
0
      public ActionResult Create([Bind(Include = "Id,Name,Address,City,State,Zip,Phone,Website,Country,ImageUrl")] Restuarant restuarant)
      {
          if (ModelState.IsValid)
          {
              db.Restuarants.Add(restuarant);
              db.SaveChanges();
              return(RedirectToAction("Index"));
          }

          return(View(restuarant));
      }
Example #5
0
        public ActionResult Create([Bind(Include = "Id,ReviewerName,Message,Rating")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(review));
        }
        public ActionResult Create([Bind(Include = "Id,ReviewerName,Body,Rating,Created")] Review review)
        {
            if (ModelState.IsValid)
            {
                review.Created = DateTime.Now;
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(review));
        }
        public ActionResult Create(RestuarantReview restuarantReview)
        {
            if (ModelState.IsValid)
            {
                restuarantReview.ReviewDate = DateTime.Now;
                db.RestuarantReview.Add(restuarantReview);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(restuarantReview));
        }
Example #8
0
        public ActionResult Create([Bind(Include = "ReviewID,Contents,EmailAddress,AlbumID,ArtistID")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AlbumID = new SelectList(db.Albums, "AlbumID", "Title", review.AlbumID);
            return(View(review));
        }
Example #9
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context =
                new ReviewContext(serviceProvider.GetRequiredService <DbContextOptions <ReviewContext> >()))
     {
         // Look for any ratings.
         if (context.RatingItem.Any())
         {
             return;                           // DB has been seeded
         }
         context.RatingItem.AddRange(
             new RatingItem
         {
             Name = "Excellent"
         },
             new RatingItem
         {
             Name = "Moderate"
         },
             new RatingItem
         {
             Name = "Needs Improvement"
         }
             );
         context.SaveChanges();
     }
 }
        public TextAnalysis SaveContentAnalysis(string content, long reviewId)
        {
            _logger.LogInformation("performing text analysis for text: {0}", content);

            var languageHolder = _analysisClient.DetectLanguage(content);

            var textAnalysis = languageHolder.Map(some =>
                                                  new TextAnalysis
            {
                ReviewId      = reviewId,
                Language      = some.Name,
                LanguageScore = some.ConfidenceScore
            }
                                                  ).Match(some => some, () => new TextAnalysis());

            var sentimentHolder = _analysisClient.DetectSentiment(content);

            var analysis = sentimentHolder.Map(some =>
                                               new TextAnalysis()
            {
                ReviewId      = textAnalysis.ReviewId,
                Language      = textAnalysis.Language,
                LanguageScore = textAnalysis.LanguageScore,
                Sentiment     = some.Sentiment.ToString(),
                NegativeScore = some.ConfidenceScores.Negative,
                NeutralScore  = some.ConfidenceScores.Neutral,
                PositiveScore = some.ConfidenceScores.Positive
            }
                                               ).Match(some => some, () => new TextAnalysis());

            _dbContext.TextAnalyses.Add(analysis);
            _dbContext.SaveChanges();

            return(analysis);
        }
Example #11
0
        // Hides a review from being public
        public ActionResult Hide(long reviewID)
        {
            var newAllReports = from c in _context.Report
                                where c.reviewID == reviewID
                                select c;

            var reviewToHide = (from r in _reviewContext.Review
                                where r.id == reviewID
                                select r).SingleOrDefault();

            reviewToHide.isHidden = true;

            _reviewContext.SaveChanges();


            _context.Report.RemoveRange(newAllReports);
            _context.SaveChanges();

            ViewData["Result"] = "Hidden";

            var allReports = from c2 in _context.Report
                             select c2;

            return(View(allReports));
        }
Example #12
0
 public IActionResult createReview(Reviews newReview)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Index"));
 }
Example #13
0
 public IActionResult Create(Recensione rev)
 {
     if (ModelState.IsValid)
     {
         _context.Add(rev);
         _context.SaveChanges();
         return(RedirectToAction("Show"));
     }
     return(View("Index"));
 }
 public IActionResult Create(Review reviews)
 {
     if (ModelState.IsValid)
     {
         _context.Reviews.Add(reviews);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Home"));
 }
Example #15
0
        public Either <string, ReviewView> Add(ReviewView reviewView)
        {
            try
            {
                var review = ReviewMapper.ToModel(reviewView);

                _dbContext.Reviews.Add(review);
                _dbContext.SaveChanges();

                _textAnalysisService.SaveContentAnalysis(review.Content, review.Id);

                return(ReviewMapper.ToView(review));
            }
            catch (Exception ex)
            {
                _logger.LogError("can't add review - ", ex);
                return("can't add review");
            }
        }
Example #16
0
 public IActionResult AddReview(Review rev)
 {
     if (ModelState.IsValid)
     {
         // add a review here and redirect to a reviews page
         _context.Add(rev);
         // OR _context.Users.Add(rev);
         _context.SaveChanges();
         return(RedirectToAction("ShowReviews"));
     }
     return(View("Index"));
 }
Example #17
0
 public IActionResult Add(Review newReview) //pass through Model name followed by variable
 {
     if (ModelState.IsValid)
     {
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     else
     {
         return(View("Index"));
     }
 }
Example #18
0
 public IActionResult NewReview(Review reviewModel)
 {
     if (ModelState.IsValid && reviewModel.Date_Of_Visit < DateTime.Now)
     {
         _context.Add(reviewModel);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     else
     {
         ViewBag.DateTimeError = "Your Date of Visit must be in the past";
         return(View("Index"));
     }
 }
Example #19
0
 public IActionResult review(Review newreview)
 {
     if (TryValidateModel(newreview))
     {
         _context.Add(newreview);
         _context.SaveChanges();
         return(Redirect("showreviews"));
     }
     else
     {
         ViewBag.errors = ModelState.Values;
         return(View("Index"));
     }
 }
Example #20
0
        public Either <string, ProductView> Add(ProductView productView)
        {
            try
            {
                var productExists = _dbContext.Products.Exists(p => p.Name.Equals(productView.Name));

                if (productExists)
                {
                    return("product already exists");
                }

                var product = ProductMapper.ToModel(productView);
                _dbContext.Products.Add(product);
                _dbContext.SaveChanges();

                return(ProductMapper.ToView(product));
            }
            catch (Exception ex)
            {
                _logger.LogError("can't add product - ", ex);
                return("can't add product");
            }
        }
Example #21
0
 public IActionResult AddReview(Review newReview)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("AllReviews"));
     }
     else
     {
         ViewBag.Errors = ModelState.Values;
         return(View("Index"));
     }
 }
        public IActionResult Create(string ReviewerName, string RestaurantName, string ReviewContent, string DateOfVisit, string StarRating)
        {
            Review NewReview = new Review
            {
                ReviewerName   = ReviewerName,
                RestaurantName = RestaurantName,
                ReviewContent  = ReviewContent,
                DateOfVisit    = DateOfVisit,
                StarRating     = StarRating
            };

            _context.Add(NewReview);
            _context.SaveChanges();
            return(Redirect("reviews"));
        }
Example #23
0
 public IActionResult Add(Review newReview)
 {
     if (ModelState.IsValid)
     {
         newReview.CreatedAt = DateTime.Now;
         newReview.UpdatedAt = DateTime.Now;
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("Display"));
     }
     else
     {
         return(View("Index"));
     }
 }
Example #24
0
        public IActionResult AddReview([Bind("Comment,Rating,User")] Review review)
        {
            var EpisodeId = (string)TempData["EpisodeId"];
            var newReview = new Review()
            {
                Comment = review.Comment,
                Rating  = review.Rating,
                MovieID = EpisodeId,
                User    = review.User,
            };

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

            return(RedirectToAction("Details", new { id = int.Parse(EpisodeId) }));
        }
Example #25
0
        // private ReviewContract _data = new ReviewContract { Name = "Nick", Comment = "Good"};


        public ReviewContract AddReview(ReviewContract data)
        {
            //data = _data;

            rev = (new Review()
            {
                Comment = data.Comment,
                Created = DateTime.Now,
                Name = data.Name
            });

            db.Reviews.Add(rev);
            db.SaveChanges();

            return(data);
        }
 public IActionResult newReview(Review review)
 //the name of the instance must be different than the asp-for on the form
 {
     if (ModelState.IsValid)
     {
         review.created_at = DateTime.Now;
         _context.Add(review);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     else
     {
         Console.WriteLine("form did not submit");
         return(View("Index"));
     }
 }
Example #27
0
 public IActionResult CreateReview(ReviewViewModel model)
 {
     if (ModelState.IsValid)
     {
         Review newReview = new Review {
             Name       = model.Name,
             Restaurant = model.Restaurant,
             ReviewText = model.ReviewText,
             VisitDate  = model.VisitDate,
             Stars      = model.Stars
         };
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("AllReviews"));
     }
     return(Redirect("/"));
 }
Example #28
0
 public IActionResult Add_Review(newReview newReview)
 {
     if (ModelState.IsValid)
     {
         Reviews createReview = new Reviews {
             ReviewerName   = newReview.ReviewerName,
             RestaurantName = newReview.RestaurantName,
             Review         = newReview.Review,
             DateOfVisit    = newReview.DateOfVisit,
             Rating         = newReview.Rating
         };
         _context.Add(createReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Index", newReview));
 }
Example #29
0
 public IActionResult WriteReview(Review model)
 {
     if (ModelState.IsValid)
     {
         Review NewReview = new Review
         {
             reviewerName   = model.reviewerName,
             restaurantName = model.restaurantName,
             review         = model.review,
             datevisited    = model.datevisited,
             rating         = model.rating
         };
         _context.reviews.Add(NewReview);
         _context.SaveChanges();
         return(RedirectToAction("AllReviews"));
     }
     return(View("index", model));
 }
Example #30
0
        public IActionResult AddReview(ReviewView model)
        {
            TryValidateModel(model);
            if (ModelState.IsValid)
            {
                Review newReview = new Review
                {
                    reviewer       = model.reviewer,
                    restaurantName = model.restaurantName,
                    review         = model.review,
                    rating         = model.rating,
                    created_at     = DateTime.Now
                };

                _context.Add(newReview);
                _context.SaveChanges();
                return(RedirectToAction("Reviews"));
            }
            return(View("Index", model));
        }
Example #31
0
        private void ReceivePack(ControllerContext context, Stream input, HttpResponseBase response)
        {
            var capabilities = new HashSet<string>(Capabilities.Split(' '));
            var requests = ProtocolUtils.ParseUpdateRequests(input, capabilities).ToList();
            if (requests.Count == 0)
            {
                response.BinaryWrite(ProtocolUtils.EndMarker);
                return;
            }

            var reportStatus = capabilities.Contains("report-status");
            var useSideBand = capabilities.Contains("side-band-64k");
            var reportBand = useSideBand ? ProtocolUtils.PrimaryBand : (int?)null;
            var failureBand = reportStatus ? reportBand : ProtocolUtils.ErrorBand;

            try
            {
                ProtocolUtils.UpdateRequest source;
                ProtocolUtils.UpdateRequest destination;
                var errors = ReadRequests(requests, out source, out destination);
                if (errors.Any(e => e.Value != null) || source == null || destination == null)
                {
                    if (reportStatus || useSideBand)
                    {
                        ReportFailure(response, failureBand, errors, "expected source and destination branches to be pushed");
                    }

                    return;
                }

                var refPrefix = Guid.NewGuid().ToString();
                source = new ProtocolUtils.UpdateRequest(
                    source.SourceIdentifier,
                    source.TargetIdentifier,
                    RepoFormat.FormatSourceRef(refPrefix, 1));
                destination = new ProtocolUtils.UpdateRequest(
                    destination.SourceIdentifier,
                    destination.TargetIdentifier,
                    RepoFormat.FormatDestinationRef(refPrefix, 1));

                var output = this.ReadPack(new[] { source, destination }, capabilities, input);
                var line = ProtocolUtils.ReadPacketLine(output).TrimEnd('\n');
                if (line != "unpack ok")
                {
                    line = line.Substring("unpack ".Length);

                    if (reportStatus || useSideBand)
                    {
                        ReportFailure(response, failureBand, errors, line);
                    }

                    return;
                }

                string id;
                try
                {
                    using (var ctx = new ReviewContext())
                    {
                        using (new NoSyncScope())
                        {
                            id = ctx.GetNextReviewId().Result;
                        }

                        ctx.Reviews.Add(new Review
                        {
                            Id = id,
                            RefPrefix = refPrefix,
                        });
                        ctx.SaveChanges();
                    }
                }
                catch (DbUpdateException ex)
                {
                    ReportFailure(response, failureBand, errors, ex.GetBaseException().Message);
                    throw;
                }

                if (useSideBand)
                {
                    var url = new UrlHelper(context.RequestContext).Action("Index", "Home", null, context.HttpContext.Request.Url.Scheme) + "#/" + id;
                    var message = string.Format("code review created:\n\n\t{0}\n\n", url);
                    response.BinaryWrite(ProtocolUtils.Band(ProtocolUtils.MessageBand, Encoding.UTF8.GetBytes(message)));
                }

                if (reportStatus)
                {
                    ReportSuccess(response, reportBand);
                }
            }
            finally
            {
                if (useSideBand)
                {
                    response.BinaryWrite(ProtocolUtils.EndMarker);
                }
            }
        }