// GET: ReviewLog public ActionResult Index() { List <ReviewLog> Logs = db.ReviewLog.ToList(); List <Deal> Deals = db.Deal.ToList(); List <ReviewLogViewModel> LogsViewModel = new List <ReviewLogViewModel>(); for (var i = 0; i < Logs.Count; i++) { var vm = new ReviewLogViewModel(Deals.Where(a => a.ASIN == Logs[i].ASIN).FirstOrDefault(), Logs[i]); LogsViewModel.Add(vm); } return(View(LogsViewModel)); }
// GET: AllReviews public ActionResult Index(string id) { // Making a list of the reviews associated with the product // Pulling all with the given ID List <ReviewLog> Logs = (from log in db.ReviewLog where log.ASIN.Equals(id) && log.CustomerReviewed == true select log).ToList(); List <Deal> Deals = db.Deal.ToList(); List <ReviewLogViewModel> LogsViewModel = new List <ReviewLogViewModel>(); for (var i = 0; i < Logs.Count; i++) { var vm = new ReviewLogViewModel(Deals.Where(a => a.ASIN == id).FirstOrDefault(), Logs[i]); LogsViewModel.Add(vm); } return(View(LogsViewModel)); }
// GET: ReviewLog/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //Create the review object from id, create deal object where the ASIN/pkey matches ReviewLog Review = db.ReviewLog.Find(id); Deal Deal = db.Deal.Where(db => db.ASIN == Review.ASIN).First(); //Create VM to pass to details view var ReviewDetailsVM = new ReviewLogViewModel(Deal, Review); ReviewDetailsVM.DaysSinceCodeGiven = (DateTime.Now - ReviewDetailsVM.SelectedDate); if (Review == null) { return(HttpNotFound()); } return(View(ReviewDetailsVM)); }