Esempio n. 1
0
        public ActionResult CreateItinPartial(ItineraryModel newItinerary)
        {
            PlacesDAL   dal = new PlacesDAL();
            PlacesModel p   = new PlacesModel();

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("UserDashboard"));
            }
            else
            {
                p = dal.GetSinglePlace(newItinerary.StartingLocationId);

                newItinerary.StartLocationLat  = p.Latitude.ToString();
                newItinerary.StartLocationLong = p.Longitude.ToString();

                UserModel user = Session["user"] as UserModel;
                newItinerary.UserId = user.UserId;

                ItineraryDAL idal = new ItineraryDAL();
                idal.CreateNewItinerary(newItinerary);

                int neededIdNumber = idal.GetMostRecentlyCreatedItinerary(user.UserId);
                idal.AddPlaceToItinerary(neededIdNumber, newItinerary.StartingLocationId);
                return(RedirectToAction("UserDashboard"));
            }
        }
Esempio n. 2
0
        public void GetAllLandmarks()
        {
            //Create itinerary & Save To DB
            int itnID = new ItineraryDAL(connectionString).CreateItinerary(new Itinerary("Sample Itinerary", DateTime.Now.AddDays(1), "This is a test description", "*****@*****.**"));
            //Create Landmarks
            Landmark fSquare = new Landmark("00002", "Fountain Square", " 520 Vine St, Cincinnati, OH 45202", "Fountain Square is the city square; features many shops, restaurants, hotels, and offices.", 39.101789, -84.512794, true, "Attraction");
            Landmark newport = new Landmark("00003", "Newport On the Levee", "1 Levee Way, Newport, KY 41071", "Newport on the Levee is a premier dining and attraction destination!", 39.094690, -84.496364, true, "Attraction");
            //Add Landmarks to DB
            int fSquareId = testLandmarkDAL.CreateLandmark(fSquare);
            int newportID = testLandmarkDAL.CreateLandmark(newport);
            //Add Landmark to Itinerary
            bool wasSuccesful = new ItineraryDAL(connectionString).AddLandmarkToItinerary(fSquareId, itnID);

            //Test
            Assert.IsTrue(wasSuccesful);
            //Add 2nd Landmark
            wasSuccesful = new ItineraryDAL(connectionString).AddLandmarkToItinerary(newportID, itnID);
            //Test
            Assert.IsTrue(wasSuccesful);
            //Get All Landmarks for an Itinerary
            List <Landmark> landmarks = testLandmarkDAL.GetAllLandmarks(itnID);

            //Should contain 2 Landmarks
            Assert.AreEqual(2, landmarks.Count);
        }
Esempio n. 3
0
        public ActionResult DeletePlaceFromItinerary(int placeId, int itineraryId)
        {
            ItineraryDAL idal = new ItineraryDAL();

            idal.RemovePlaceFromItinerary(placeId, itineraryId);

            return(RedirectToAction("UserDashboard"));
        }
Esempio n. 4
0
        public ActionResult DeleteItinerary(int itineraryId)
        {
            ItineraryDAL idal = new ItineraryDAL();

            idal.DeleteItinerary(itineraryId);

            return(RedirectToAction("UserDashboard"));
        }
Esempio n. 5
0
 public ActionResult SavedItinerary(PlacesModel newPlaceForUser)
 {
     if (Session["user"] != null)
     {
         PlacesDAL    pdal = new PlacesDAL();
         ItineraryDAL idal = new ItineraryDAL();
         UserModel    user = Session["user"] as UserModel;
         newPlaceForUser.UserId = user.UserId;
         List <ItineraryModel> userItinerary = idal.GetAllItinerary(user.UserId);
         var save       = pdal.CreatePlaceForUser(newPlaceForUser);
         var saveToItin = idal.AddPlaceToItinerary(userItinerary[0].Id, save);
         return(Json(new { result = "OK" }));
     }
     return(View("LoginRegister"));
 }
Esempio n. 6
0
        public void RemoveLandmarkFromItnTest()
        {
            //Create itinerary & Save To DB
            int itnID = new ItineraryDAL(connectionString).CreateItinerary(new Itinerary("Sample Itinerary", DateTime.Now.AddDays(1), "This is a test description", "*****@*****.**"));
            //Create Landmarks
            Landmark fSquare = new Landmark("00002", "Fountain Square", " 520 Vine St, Cincinnati, OH 45202", "Fountain Square is the city square; features many shops, restaurants, hotels, and offices.", 39.101789, -84.512794, true, "Attraction");
            //Add Landmarks to DB
            int fSquareId = testLandmarkDAL.CreateLandmark(fSquare);

            //Add Landmark to Itinerary
            new ItineraryDAL(connectionString).AddLandmarkToItinerary(fSquareId, itnID);
            bool wasSuccessful = new ItineraryDAL(connectionString).RemoveLandmarkFromItinerary(fSquareId, itnID);

            //Test
            Assert.IsTrue(wasSuccessful);
        }
Esempio n. 7
0
        public ActionResult Route()
        {
            PlacesDAL pdal = new PlacesDAL();

            if (Session["user"] != null)
            {
                UserModel    user = Session["user"] as UserModel;
                ItineraryDAL idal = new ItineraryDAL();
                List <ItineraryPlacesModel> model = idal.GetAllItineraryPlacesForUser(user.UserId);

                return(View("Route", model));
            }
            else
            {
                return(RedirectToAction("LoginRegister"));
            }
        }
Esempio n. 8
0
        public ActionResult CreateTravelRoute(int itineraryId, List <int> placeIds)
        {
            UserModel    user = Session["user"] as UserModel;
            ItineraryDAL idal = new ItineraryDAL();

            ItineraryModel newItin = idal.GetAllItineraryInfo(itineraryId);

            idal.DeleteItinerary(itineraryId);
            idal.CreateNewItinerary(newItin);
            int neededIdNumber = idal.GetMostRecentlyCreatedItinerary(user.UserId);

            foreach (var i in placeIds)
            {
                idal.AddPlaceToItinerary(neededIdNumber, i);
            }

            return(RedirectToAction("Route"));
        }
Esempio n. 9
0
        public ActionResult SavePlaceToItineraryFromList(int placeId)
        {
            if (Session["user"] != null)
            {
                PlacesDAL             pdal          = new PlacesDAL();
                ItineraryDAL          idal          = new ItineraryDAL();
                UserModel             user          = Session["user"] as UserModel;
                List <ItineraryModel> userItinerary = idal.GetAllItinerary(user.UserId);
                if (userItinerary.Count > 0)
                {
                    var saveToItin = idal.AddPlaceToItinerary(userItinerary[0].Id, placeId);

                    return(RedirectToAction("UserDashboard"));
                }
                else
                {
                    return(RedirectToAction("CreateItinerary"));
                }
            }
            return(View("LoginRegister"));
        }
Esempio n. 10
0
        public ActionResult ItinPartial()
        {
            List <ItineraryPlacesModel> model    = new List <ItineraryPlacesModel>();
            UserModel             user           = Session["user"] as UserModel;
            ItineraryDAL          itdal          = new ItineraryDAL();
            List <ItineraryModel> itinerary      = itdal.GetAllItinerary(user.UserId);
            List <int>            listOfPlaceIds = itdal.GetItinerary(user.UserId);

            foreach (var i in itinerary)
            {
                ItineraryPlacesModel singleIntinForUser = new ItineraryPlacesModel();
                singleIntinForUser.Itinerary = i;
                List <PlacesModel> listOfPlacesInItin = new List <PlacesModel>();
                foreach (var singlePlaceId in listOfPlaceIds)
                {
                    PlacesModel newPlaceFromItin = new PlacesModel();
                    newPlaceFromItin = dal.GetSinglePlace(singlePlaceId);
                    listOfPlacesInItin.Add(newPlaceFromItin);
                }
                singleIntinForUser.Places = listOfPlacesInItin;
                model.Add(singleIntinForUser);
            }
            return(View("ItinPartial", model));
        }