public IQueryable <ReviewDetails> RestaurantReviewRating(ReviewRating reviewRating) { try { List <ReviewDetails> restaurantRatings = new List <ReviewDetails>(); IQueryable <TblRating> rating; DataAccessLayer.DataEntity.ReviewRating review = new DataAccessLayer.DataEntity.ReviewRating { Rating = reviewRating.Rating, ReviewComments = reviewRating.ReviewComments, RestaurantID = reviewRating.RestaurantID, CustomerId = reviewRating.CustomerId }; rating = dalReviewRepository.RestaurantReviewRating(review); foreach (var item in rating) { ReviewDetails reviewDetails = new ReviewDetails { Rating = item.Rating, RestaurantId = item.TblRestaurantId, Review = item.Comments, CustId = item.TblCustomerId, RestaurantName = item.TblRestaurant.Name }; restaurantRatings.Add(reviewDetails); } return(restaurantRatings.AsQueryable()); } catch (Exception ex) { throw ex; } }
public ReviewDetails GetReviewById(int id) { var dbReview = db.movie_Review.Where(r => r.id_Review == id).FirstOrDefault(); ReviewDetails review = new ReviewDetails() { Reviewer = GetReviewer(dbReview.id_Reviewer).FirstName, ReviewTitle = dbReview.ReviewTitle, MovieTitle = dbReview.MovieTitle, SoundPoints = dbReview.SoundPoints, TotalPoints = dbReview.TotalScore, ActingPoints = dbReview.ActingPoints, OverAllPoints = dbReview.OverAllPoints, EffectsPoints = dbReview.EffectsPoints, ScriptPoints = dbReview.ScriptPoints, Review = dbReview.Review }; // short date DateTime d = dbReview.ReviewDate.Value; review.ReviewDate = d.ToShortDateString(); review = GetMovieDetails(review); return(review); }
public IQueryable <ReviewDetails> GetRestaurantRating(int restaurantID) { try { List <ReviewDetails> restaurantRatings = new List <ReviewDetails>(); IQueryable <TblRating> rating; rating = dalReviewRepository.GetReviewRating(restaurantID); foreach (var item in rating) { ReviewDetails reviewDetails = new ReviewDetails { Rating = item.Rating, RestaurantId = item.TblRestaurantId, Review = item.Comments, CustId = item.TblCustomerId, RestaurantName = item.TblRestaurant.Name }; restaurantRatings.Add(reviewDetails); } return(restaurantRatings.AsQueryable()); } catch (Exception ex) { throw ex; } }
public CarModel getCarData() { EmiDetails e = new EmiDetails { cost = "10,719", duration = "5 years" }; ReviewDetails r = new ReviewDetails { rating = 3, totalReviewCount = 312 }; PriceDetails p = new PriceDetails { price = "6.62 Lakhs", carType = "On - Road, Mumbai" }; CarModel model = new CarModel { ReviewDetail = r, EmiDetail = e, PriceDetail = p, cityList = getCityList(), versionList = getVersionList(), name = "BMW M2", imageUrl = "https://imgd.aeplcdn.com/664x374/n/cw/ec/26742/swift-exterior-right-front-three-quarter-117655.gif?q=85" }; return(model); }
public async Task <ActionResult> ReviewProduction(int id) { ProductionService service = new ProductionService(); ReviewDetails reviewDetails = new ReviewDetails(); /*{ * ProductId, * ProductionName, * MinPrice, * MaxPrice, * Picture, * Color * }*/ // get product info by productId reviewDetails.product = await service.getProductionByProductId(id); /* * { * ReviewId, * Title, * Content, * OverallRating, * UserName, * ReviewDate, * }*/ // get all reviews about a product List <ReviewProduction> reviewList = await service.getReviewsByProductId(id); reviewDetails.reviewList = reviewList; /* * rating.oneStarReviewNumber = reviewNumber.Count; * rating.twoStarReviewNumber = reviewNumber.Count; * rating.threeStarReviewNumber = reviewNumber.Count; * rating.fourStarReviewNumber = reviewNumber.Count; * rating.fiveStarReviewNumber = reviewNumber.Count; * * rating.oneStarReviewPercent * rating.twoStarReviewPercent * rating.threeStarReviewPercent * rating.fourStarReviewPercent * rating.fiveStarReviewPercent * * rating.overrallRating */ // get all rating information of a product reviewDetails.rating = await service.getRatingByProductId(id); // render View return(View(reviewDetails)); }
public ReviewDetails GetMovieDetails(ReviewDetails review) { // used for http://www.omdbapi.com //First Check if movie exists in db var movie = db.movie_Details.Where(m => m.Title == review.MovieTitle).FirstOrDefault(); if (movie == null) { // Get Movie var client = new WebClient(); string url = "http://www.omdbapi.com?t=" + review.MovieTitle + "&apikey=" + apiKey; var response = client.DownloadString(url); // Save movie to db var m = JsonConvert.DeserializeObject <MovieDetails>(response); var dbMovie = new movie_Details() { Actors = m.Actors, DVD = m.DVD, Director = m.Director, Genre = m.Genre, Production = m.Production, Rated = m.Rated, Released = m.Released, Runtime = m.Runtime, Writer = m.Writer, Awards = m.Awards, BoxOffice = m.BoxOffice, IMDBID = m.IMDBID, IMDBRating = m.IMDBRating, IMDBVotes = m.IMDBVotes, Country = m.Country, Metascore = m.Metascore, Plot = m.Plot, Title = m.Title, Poster = m.Poster }; db.movie_Details.AddOrUpdate(dbMovie); var er = db.GetValidationErrors(); db.SaveChanges(); review.Movie = new MovieDetails() { Actors = m.Actors, DVD = m.DVD, Director = m.Director, Genre = m.Genre, Production = m.Production, Rated = m.Rated, Released = m.Released, Runtime = m.Runtime, Writer = m.Writer, Awards = m.Awards, BoxOffice = m.BoxOffice, IMDBID = m.IMDBID, IMDBRating = m.IMDBRating, IMDBVotes = m.IMDBVotes, Country = m.Country, Metascore = m.Metascore, Plot = m.Plot, Title = m.Title, Poster = m.Poster }; } else { review.Movie = new MovieDetails() { Title = movie.Title, Plot = movie.Plot, Actors = movie.Actors, Director = movie.Director, Rated = movie.Rated, Production = movie.Production, Released = movie.Released, Runtime = movie.Runtime, Genre = movie.Genre, Writer = movie.Writer, DVD = movie.DVD, Poster = movie.Poster }; } return(review); }
public ActionResult ReviewProduction(int id) { DBModelContainer db = new DBModelContainer(); ReviewDetails reviewDetails = new ReviewDetails(); Production production = (from p in db.Products join pDetail in db.ProductDetails on p.ProductId equals pDetail.ProductId where p.ProductId == id select new { p.ProductId, p.Name, pDetail.Price, pDetail.Picture, pDetail.Color } into t1 group t1 by t1.ProductId into g select new Production { ProductId = g.Key, ProductionName = g.FirstOrDefault().Name, MinPrice = g.Min(m => m.Price), MaxPrice = g.Max(m => m.Price), Picture = g.FirstOrDefault().Picture, Color = g.FirstOrDefault().Color }).FirstOrDefault(); reviewDetails.product = production; List <ReviewProduction> reviewList = (from r in db.Reviews join u in db.Users on r.UserId equals u.UserId where r.ProductId == id select new ReviewProduction { ReviewId = r.ReviewId, Title = r.Title, Content = r.Content, OverallRating = r.OverallRating, UserName = u.UserName, ReviewDate = r.ReviewDate, }).ToList(); reviewDetails.reviewList = reviewList; var reviewNumbers = (from r in reviewList group r by new { r.OverallRating } into g select new { OverrallRating = g.Key.OverallRating, Count = g.Count() }).ToList(); Rating rating = new Rating(); // calculate number and percent of each rate foreach (var reviewNumber in reviewNumbers) { if (reviewNumber.OverrallRating == 1) { rating.oneStarReviewNumber = reviewNumber.Count; } else if (reviewNumber.OverrallRating == 2) { rating.twoStarReviewNumber = reviewNumber.Count; } else if (reviewNumber.OverrallRating == 3) { rating.threeStarReviewNumber = reviewNumber.Count; } else if (reviewNumber.OverrallRating == 4) { rating.fourStarReviewNumber = reviewNumber.Count; } else if (reviewNumber.OverrallRating == 5) { rating.fiveStarReviewNumber = reviewNumber.Count; } } rating.oneStarReviewPercent = Convert.ToDecimal(String.Format("{0:0.0000}", rating.oneStarReviewNumber * 100 / reviewList.Count())); rating.twoStarReviewPercent = Convert.ToDecimal(String.Format("{0:0.0000}", rating.twoStarReviewNumber * 100 / reviewList.Count())); rating.threeStarReviewPercent = Convert.ToDecimal(String.Format("{0:0.0000}", rating.threeStarReviewNumber * 100 / reviewList.Count())); rating.fourStarReviewPercent = Convert.ToDecimal(String.Format("{0:0.0000}", rating.fourStarReviewNumber * 100 / reviewList.Count())); rating.fiveStarReviewPercent = Convert.ToDecimal(String.Format("{0:0.0000}", rating.fiveStarReviewNumber * 100 / reviewList.Count())); // calculate average overral rating decimal overrall = 0; foreach (ReviewProduction review in reviewList) { overrall += review.OverallRating; } overrall = overrall / reviewList.Count(); overrall = Convert.ToDecimal(String.Format("{0:0.0}", overrall)); rating.overrallRating = overrall; reviewDetails.rating = rating; // render View return(View(reviewDetails)); }
public void SaveDocument() { newPhaseReviewPlanningModel.PlanningPhase = Planning_Phase_tbx.Text; newPhaseReviewPlanningModel.ProjectName = Project_Name_tbx.Text; newPhaseReviewPlanningModel.ProjectManager = Project_Manager_tbx.Text; newPhaseReviewPlanningModel.ProjectSponsor = Project_Sponsor_tbx.Text; newPhaseReviewPlanningModel.ReportingPeriod = txtReportingPeriod.Text; newPhaseReviewPlanningModel.ReportPrepDate = txtReportPreparationDate.Text; newPhaseReviewPlanningModel.RepportPreparedBy = txtReportPreparedBy.Text; /*newPhaseReviewPlanningModel.RepportPreparedBy = txtPreparedBy.Text; * newPhaseReviewPlanningModel.ReportPrepDate = txtPrepDate.Text; * newPhaseReviewPlanningModel.ReportingPeriod = txtReportingPeriod.Text;*/ newPhaseReviewPlanningModel.Summary = Summary_tbx.Text; newPhaseReviewPlanningModel.ProjectSchedule = Project_Schedule_tbx.Text; newPhaseReviewPlanningModel.ProjectExpense = Project_Expenses_tbx.Text; newPhaseReviewPlanningModel.ProjectDeliverables = Project_Deliverables_tbx.Text; newPhaseReviewPlanningModel.ProjectRisks = Project_Risks_tbx.Text; newPhaseReviewPlanningModel.ProjectIssues = Project_Issues_tbx.Text; newPhaseReviewPlanningModel.ProjectChanges = Project_Changes_tbx.Text; newPhaseReviewPlanningModel.SupportingDocumentation = Supporting_Documentation_tbx.Text; List <ReviewDetails> reviews = new List <ReviewDetails>(); int RowCount = REVIEW_DETAILS_dgv.RowCount; for (int i = 0; i < RowCount - 1; i++) { ReviewDetails review = new ReviewDetails(); var ReviewCategory = REVIEW_DETAILS_dgv.Rows[i].Cells[0].Value?.ToString() ?? ""; var ReviewQuestion = REVIEW_DETAILS_dgv.Rows[i].Cells[1].Value?.ToString() ?? ""; var Answer = REVIEW_DETAILS_dgv.Rows[i].Cells[2].Value?.ToString() ?? ""; var Variance = REVIEW_DETAILS_dgv.Rows[i].Cells[3].Value?.ToString() ?? ""; review.ReviewCategory = ReviewCategory; review.ReviewQuestion = ReviewQuestion; review.Answer = Answer; review.Variance = Variance; reviews.Add(review); } newPhaseReviewPlanningModel.Reviews = reviews; newPhaseReviewPlanningModel.SupportingDocumentation = Supporting_Documentation_tbx.Text; List <VersionControl <PhaseReviewPlanningModel> .DocumentModel> documentModels = versionControl.DocumentModels; //MessageBox.Show(JsonConvert.SerializeObject(newPhaseReviewPlanningModel), "save", MessageBoxButtons.OK); if (!versionControl.isEqual(currentPhaseReviewPlanningModel, newPhaseReviewPlanningModel)) { VersionControl <PhaseReviewPlanningModel> .DocumentModel documentModel = new VersionControl <PhaseReviewPlanningModel> .DocumentModel(newPhaseReviewPlanningModel, DateTime.Now, VersionControl <PhaseReviewPlanningModel> .generateID()); documentModels.Add(documentModel); versionControl.DocumentModels = documentModels; currentPhaseReviewPlanningModel = JsonConvert.DeserializeObject <PhaseReviewPlanningModel>(JsonConvert.SerializeObject(newPhaseReviewPlanningModel)); string json = JsonConvert.SerializeObject(versionControl); JsonHelper.saveDocument(json, Settings.Default.ProjectID, "PhaseReviewPlanning"); MessageBox.Show("Phase Review Planning Form saved successfully", "save", MessageBoxButtons.OK); } }