Example #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"));
            }
        }