Exemple #1
0
        public PartialViewResult Favorite(int routeID, bool makeFavorite)
        {
            FavoriteModel fm = new FavoriteModel((Guid)Membership.GetUser().ProviderUserKey, routeID);
            if (makeFavorite)
                FavoriteModel.insertFavorite(fm);
            else
                FavoriteModel.deleteFavorite(fm);

            RouteModel rm = new RouteModel(routeID);
            return PartialView("Routes/_ListRoutesElement", rm);
        }
Exemple #2
0
        public static void deleteFavorite(FavoriteModel fm)
        {
            Favorite favorite = (from r in _db.Favorites
                          where r.Route_ID == fm.routeID
                          && r.User_ID == fm.userID
                          select r).SingleOrDefault();

            if (favorite != null)
            {
                _db.Favorites.DeleteOnSubmit(favorite);
                _db.SubmitChanges();
            }
        }
Exemple #3
0
        public static void insertFavorite(FavoriteModel fm)
        {
            // Check if already favored
            Favorite favorite = (from f in _db.Favorites
                                 where f.Route_ID == fm.routeID
                                 && f.User_ID == fm.userID
                                 select f).SingleOrDefault();

            if (favorite == null)
            {
                favorite = new Favorite();
                favorite.User_ID = fm.userID;
                favorite.Route_ID = fm.routeID;
                _db.Favorites.InsertOnSubmit(favorite);
                _db.SubmitChanges();

                // Create event that this route has been favored
                RouteFavoredEvent rfe = new RouteFavoredEvent(favorite);
                rfe.save();
            }
        }