Exemplo n.º 1
0
        public ActionResult Show(int id)
        {
            var model = new RestroomModel();
            var viewModel = model.getRestroomWithRating(id);

            return View(viewModel);
        }
Exemplo n.º 2
0
        public ActionResult NewRating(RatingModel ratingModel)
        {
            string val1 = System.Web.HttpContext.Current.User.Identity.Name;
            int userId = Int32.Parse(val1);
            ratingModel.UserId = userId;
            ratingModel.add();

            var model = new RestroomModel();
            var viewModel = model.getRestroomWithRating(ratingModel.RestroomId);


            return RedirectToAction("Show", "Restroom", new { id = viewModel.restroomModel.id });
        }
Exemplo n.º 3
0
 public void AddRestroom(RestroomModel bathroom)
 {
     using (var db = new shamethethronesContext())
     {
         Restroom newBathroom = new Restroom();
         newBathroom.userId = bathroom.userId;
         newBathroom.address = bathroom.Address;
         newBathroom.city = bathroom.City; // commented out until db is changed 
         newBathroom.state = bathroom.State; 
         newBathroom.zipCode = Int32.Parse(bathroom.ZipCode); 
         newBathroom.gender = bathroom.Gender;
         newBathroom.description = bathroom.Description;
         newBathroom.coordX = bathroom.coordX;
         newBathroom.coordY = bathroom.coordY;
         db.Restrooms.Add(newBathroom);
         db.SaveChanges(); //until testing is done
         bathroom.id = newBathroom.id; // sets the id so we can get it later
     }
 }
Exemplo n.º 4
0
        public RestroomWithRatingModel getRestroomWithRating(int restroomId)
        {
            using (var db = new shamethethronesContext())
            {
                Restroom restroomModel = db.Restrooms.Single(x => x.id == restroomId);
                var ratings = db.Ratings.Where(x => x.restroomId == restroomId).OrderByDescending(x => x.id).Take(50).ToList();


                var restroom = new RestroomModel(restroomModel);

                var ratingsListModel = new RatingListModel(ratings);
                
                var restroomWithRating = new RestroomWithRatingModel();
                restroomWithRating.restroomModel = restroom;
                restroomWithRating.ratingModels = ratingsListModel;

                return restroomWithRating;
            } 
        }
Exemplo n.º 5
0
 public ActionResult New(RestroomModel restroom)
 {
     restroom.userId = User.Identity.getUser().Id;
     restroom.AddRestroom(restroom);
     return RedirectToAction("Rate", new { id = restroom.id });
 }