Exemple #1
0
        public void PopulateDriveTimes()
        {
            using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
            {
                var sources      = context.Places.ToList();
                var conns        = context.Connections.Select(p => p);
                var destinations = sources;

                foreach (var source in sources)
                {
                    foreach (var destination in destinations)
                    {
                        if (source.Name == destination.Name)
                        {
                            continue;
                        }

                        var _conxn = conns.Where(x => x.SourceId == source.Id && x.DestinationId == destination.Id).FirstOrDefault();
                        if (_conxn != null && !_conxn.DrivingTime.HasValue)
                        {
                            double driveTime = _CalculateDrivingTime(source.Name, destination.Name);
                            if (driveTime > 0)
                            {
                                _conxn.DrivingTime = (decimal)driveTime;
                                context.SaveChanges();
                            }
                        }
                    }
                }

                context.SaveChanges();
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="destinations"></param>
        /// <returns></returns>
        public static DomingoBlError GetAllDestinations(out List <Destination> destinations)
        {
            destinations = null;

            try
            {
                // get all desitions, reverse order by weightage
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    var _allDestinations = context.Destinations.Select(p => p).OrderByDescending(p => p.Weightage);
                    if (_allDestinations != null)
                    {
                        destinations = _allDestinations.ToList();
                    }
                }
            }

            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="country"></param>
        /// <param name="destinations"></param>
        /// <returns></returns>
        public static DomingoBlError GetDestinationsForCountry(string country, out List <Destination> destinations)
        {
            destinations = null;

            try
            {
                // get all desitions that matches the continent, reverse order by weightage
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    destinations = context.Destinations
                                   .Where(p => p.Country == country && p.Name != country).OrderByDescending(p => p.Weightage).ToList();
                }
            }

            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="search"></param>
        /// <param name="subDestinationList"></param>
        /// <returns></returns>
        public static DomingoBlError SearchSubDestination(string search, out List <SubDestination> subDestinationList)
        {
            subDestinationList = new List <SubDestination>();

            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    subDestinationList.AddRange(context.SubDestinations.Where(p => p.Name == search || p.Type == search).ToList());
                }
            }

            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #5
0
        public void PopulateTransitRoutes()
        {
            var originIds      = new List <int>();
            var destinationIds = new List <int>();

            using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
            {
                var places = context.Places.Select(p => p);
                foreach (var p in places)
                {
                    originIds.Add(p.Id);
                    destinationIds.Add(p.Id);
                }
            }

            foreach (int xId in originIds)
            {
                foreach (int yId in destinationIds)
                {
                    if (xId != yId)
                    {
                        System.Threading.Thread.Sleep(200);
                        _SaveTransitDetails(xId, yId, new DateTime(2017, 6, 1, 2, 0, 0));

                        System.Threading.Thread.Sleep(200);
                        _SaveTransitDetails(xId, yId, new DateTime(2017, 6, 1, 8, 0, 0));

                        System.Threading.Thread.Sleep(200);
                        _SaveTransitDetails(xId, yId, new DateTime(2017, 6, 1, 14, 0, 0));
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="templateStep"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> SaveTripTemplateStep(TripTemplateStep templateStep)
        {
            try
            {
                if (templateStep != null)
                {
                    using (var context = new TravelogyDevEntities1())
                    {
                        var _tripTemmplateStep = context.TripTemplateSteps.Where(p => p.TripTemplateId == templateStep.TripTemplateId &&
                                                                                 p.TripTemplateStepIdentifier == templateStep.TripTemplateStepIdentifier).FirstOrDefault();

                        if (_tripTemmplateStep != null)
                        {
                            _tripTemmplateStep.ShortDescription    = templateStep.ShortDescription;
                            _tripTemmplateStep.LongDescription     = templateStep.LongDescription;
                            _tripTemmplateStep.NightStay           = templateStep.NightStay;
                            _tripTemmplateStep.ThumbnailPath       = templateStep.ThumbnailPath;
                            _tripTemmplateStep.Destination         = templateStep.Destination;
                            _tripTemmplateStep.TypicalDurationDays = templateStep.TypicalDurationDays;
                            _tripTemmplateStep.TopAttractions      = templateStep.TopAttractions;

                            await context.SaveChangesAsync();
                        }

                        if (string.IsNullOrEmpty(templateStep.TripTemplateStepIdentifier))
                        {
                            _tripTemmplateStep = new TripTemplateStep()
                            {
                                TripTemplateId      = templateStep.TripTemplateId,
                                ShortDescription    = templateStep.ShortDescription,
                                LongDescription     = templateStep.LongDescription,
                                NightStay           = templateStep.NightStay,
                                ThumbnailPath       = templateStep.ThumbnailPath,
                                Destination         = templateStep.Destination,
                                TypicalDurationDays = templateStep.TypicalDurationDays,
                                TopAttractions      = templateStep.TopAttractions,
                            };

                            context.TripTemplateSteps.Add(_tripTemmplateStep);
                            await context.SaveChangesAsync();

                            _tripTemmplateStep.TripTemplateStepIdentifier = string.Format("{0}-{1}", _tripTemmplateStep.TripTemplateId, _tripTemmplateStep.Id);
                            await context.SaveChangesAsync();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_messageList"></param>
        /// <returns></returns>
        public static DomingoBlError GetMessagesForAdmin(out List <Thread> _messageList)
        {
            _messageList = null;

            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    // get all the threads, sorted by the latest one first
                    var threads = context.Threads.Select(p => p).OrderByDescending(p => p.MostRecentPostDate);
                    _messageList = threads.ToList();
                }

                return(new DomingoBlError()
                {
                    ErrorCode = 0, ErrorMessage = ""
                });
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }
        }
        /// <summary>
        /// get the xchange rate from our own database
        /// </summary>
        /// <param name="fromCurrency"></param>
        /// <param name="toCurrency"></param>
        /// <returns></returns>
        private static double _GetCachedCurrencyXchangeRate(string fromCurrency, string toCurrency)
        {
            try
            {
                double xRate = 0;

                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    var currencyXcgObj = context.CurrencyExchanges.Where(p => p.CurrencyFrom.ToUpper() == fromCurrency.ToUpper() && p.CurrencyTo.ToUpper() == toCurrency.ToUpper()).FirstOrDefault();
                    if (currencyXcgObj != null)
                    {
                        if ((currencyXcgObj.DateOfUpdate - DateTime.Now).TotalDays > 1)
                        {
                            return(0);
                        }

                        xRate = (double)currencyXcgObj.XchangeRate;
                    }
                }

                return(xRate);
            }
            catch (Exception)
            {
                return(0);
            }
        }
        public static void PopulateAllFlights()
        {
            var fromIDs = new List <int>();
            var toIDs   = new List <int>();

            using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
            {
                var airports = context.Airports.Where(p => p.Class == "A" || p.Class == "B");
                foreach (var airport in airports)
                {
                    fromIDs.Add(airport.Id);
                    toIDs.Add(airport.Id);
                }
            }

            foreach (var fromId in fromIDs)
            {
                foreach (var toId in toIDs)
                {
                    if (fromId == toId)
                    {
                        continue;
                    }

                    //System.Threading.Thread.Sleep(1000);
                    FindAndSaveFlights(fromId, toId, 2017, 6, 2);
                }
            }
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> TraceSession(string userId, string url)
        {
            try
            {
                var session = new AspNetUserSession()
                {
                    AspNetUserId = userId, ActionTimeStamp = DateTime.Now, ActionUrl = url
                };
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    context.AspNetUserSessions.Add(session);
                    await context.SaveChangesAsync();
                }

                return(new DomingoBlError()
                {
                    ErrorCode = 0, ErrorMessage = ""
                });
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }
        }
Exemple #11
0
        public void PopulateAirportAddress()
        {
            double latitude, longitude;

            using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
            {
                var airports = context.Airports.Where(p => p.Id >= 100050);
                foreach (var airport in airports)
                {
                    if (airport.Lattitude.HasValue)
                    {
                        continue;
                    }

                    _GeocodePlace(airport.Name, out latitude, out longitude);
                    if (latitude != 0.0 && longitude != 0.0)
                    {
                        airport.Lattitude = (decimal)latitude;
                        airport.Longitude = (decimal)longitude;
                        latitude          = 0; longitude = 0;
                    }
                }

                context.SaveChanges();
            }
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tm"></param>
        /// <returns></returns>
        public static DomingoBlError AddToThread(ThreadMessage tm)
        {
            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    // update the MostRecentPostDate of the parent thread
                    var thread = context.Threads.Find(tm.ThreadId);
                    thread.MostRecentPostDate = DateTime.Now;

                    // add the message
                    context.ThreadMessages.Add(tm);

                    // commit
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #13
0
        //private static Connection

        public static DomingoBlError GetSuggestedTrip(string startingPoint, int Days, List <TripInterest> interests, out List <Place> suggestions)
        {
            suggestions = new List <Place>();
            Dictionary <int, PlaceScore> placeAndScore = new Dictionary <int, PlaceScore>();

            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    // get the starting point
                    var startingPlace = context.Places.Where(p => p.Name == startingPoint).FirstOrDefault();
                    if (startingPlace == null)
                    {
                        throw new ApplicationException("Invalid Starting City");
                    }

                    // add starting point
                    suggestions.Add(startingPlace);

                    // calculate scores
                    CalculateScores(interests, placeAndScore, context);

                    // remove starting point duplicate
                    if (placeAndScore.ContainsKey(startingPlace.Id))
                    {
                        placeAndScore.Remove(startingPlace.Id);
                    }

                    // sort by scores
                    placeAndScore = placeAndScore.OrderByDescending(x => x.Value.Score).ToDictionary(x => x.Key, x => x.Value);

                    int tripDays = 0;
                    foreach (var x in placeAndScore)
                    {
                        suggestions.Add(x.Value.Place);
                        tripDays += x.Value.Place.UsualDays.Value;

                        if (tripDays > Days)
                        {
                            break;
                        }
                    }

                    suggestions = OptimizeTrip(suggestions, context);
                }

                return(new DomingoBlError()
                {
                    ErrorCode = 0, ErrorMessage = ""
                });
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }
        }
Exemple #14
0
        public ActionResult TripTemplates()
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();

            return(View(context.TripTemplates.OrderBy(p => p.Id)));
        }
Exemple #15
0
        public ActionResult TripProviders()
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();

            return(View(context.TripProviders));
        }
Exemple #16
0
        public ActionResult Places()
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();

            return(View(context.Places));
        }
Exemple #17
0
        public void PopulateAirConnectivityTimes()
        {
            using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
            {
                var sources      = context.Places.ToList();
                var conns        = context.Connections.Select(p => p);
                var airportconns = context.AirportConnections.Select(p => p);
                var destinations = sources;

                foreach (var source in sources)
                {
                    foreach (var destination in destinations)
                    {
                        // if the source is destination - skip
                        if (source.Name == destination.Name)
                        {
                            continue;
                        }

                        // if the places do not have airports - skip
                        if (String.IsNullOrEmpty(source.NearestAirport) || String.IsNullOrEmpty(destination.NearestAirport))
                        {
                            continue;
                        }

                        // if the places are near the same airport - skip
                        if (source.NearestAirport == destination.NearestAirport)
                        {
                            continue;
                        }

                        // ok now that we have two airports - calculate flight time
                        int fromAirport = context.Airports.Where(p => p.Code == source.NearestAirport).FirstOrDefault().Id;
                        int toAirport   = context.Airports.Where(p => p.Code == destination.NearestAirport).FirstOrDefault().Id;

                        var flights = airportconns.Where(p => p.SourceId == fromAirport && p.DestinationId == toAirport);
                        if (flights == null || flights.Count() == 0) // there are no connecting flightts
                        {
                            continue;
                        }

                        var averageFlightTime = flights.Average(p => p.FlightTime1);
                        var minFLightTime     = flights.Min(p => p.FlightTime1);
                        var maxFlightTime     = flights.Max(p => p.FlightTime1);

                        var conn = conns.Where(p => p.SourceId == source.Id && p.DestinationId == destination.Id).FirstOrDefault();
                        if (conn != null)
                        {
                            conn.MaxFlightTime = maxFlightTime + source.NearestAirportDriveTime + destination.NearestAirportDriveTime;
                            conn.MinFlightTime = minFLightTime + source.NearestAirportDriveTime + destination.NearestAirportDriveTime;
                            conn.AvgFlightTime = averageFlightTime + source.NearestAirportDriveTime + destination.NearestAirportDriveTime;
                            context.SaveChanges();
                        }
                    }
                }
            }
        }
Exemple #18
0
        public ActionResult TripBookingAccommodations()
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var model   = context.View_TripBookingAccommodation;

            return(View(model));
        }
Exemple #19
0
        public ActionResult EditTripProvider(int id)
        {
            _CheckForAdminAccess();

            var context       = new TravelogyDevEntities1();
            var _tripProvider = context.TripProviders.Find(id);

            return(View(_tripProvider));
        }
Exemple #20
0
        private void _SaveTransitDetails(int originId, int destinationId, DateTime depTime)
        {
            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    var origin      = context.Places.Find(originId);
                    var destination = context.Places.Find(destinationId);

                    if (origin == null || destination == null)
                    {
                        return;
                    }

                    var transitDirectionRequest = new DirectionsRequest
                    {
                        Origin        = origin.Name,
                        Destination   = destination.Name,
                        TravelMode    = TravelMode.Transit,
                        DepartureTime = depTime,
                        ApiKey        = GoogleKey
                    };

                    DirectionsResponse transitDirections = GoogleMaps.Directions.Query(transitDirectionRequest);

                    if (transitDirections.Status == DirectionsStatusCodes.OK)
                    {
                        string jsonStr      = JsonConvert.SerializeObject(transitDirections);
                        string transitStart = transitDirections.Routes.FirstOrDefault().Legs.FirstOrDefault().DepartureTime.Text;
                        var    _dbVal       = context.Transits.Where(p => p.SourceId == originId &&
                                                                     p.DestinationId == destinationId &&
                                                                     p.departure_time == transitStart);

                        if (_dbVal.Count() == 0)
                        {
                            var _transitDetail = new Transit();

                            _transitDetail.SourceId      = originId;
                            _transitDetail.DestinationId = destinationId;

                            _transitDetail.Distance       = transitDirections.Routes.FirstOrDefault().Legs.FirstOrDefault().Distance.Value / 1000;
                            _transitDetail.departure_time = transitStart;
                            _transitDetail.arrival_time   = transitDirections.Routes.FirstOrDefault().Legs.FirstOrDefault().ArrivalTime.Text;
                            _transitDetail.Transit_Time   = (decimal)transitDirections.Routes.FirstOrDefault().Legs.FirstOrDefault().Duration.Value.TotalHours;

                            context.Transits.Add(_transitDetail);

                            context.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string _debug = ex.Message;
            }
        }
Exemple #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="trip"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> SaveTrip(Trip trip)
        {
            try
            {
                using (var context = new TravelogyDevEntities1())
                {
                    var _dbTrip = context.Trips.Find(trip.Id);
                    if (_dbTrip != null)
                    {
                        if (trip.EndDate.HasValue)
                        {
                            _dbTrip.EndDate = trip.EndDate;
                        }
                        if (trip.StartDate.HasValue)
                        {
                            _dbTrip.StartDate = trip.StartDate;
                        }
                        _dbTrip.PaxAdults = trip.PaxAdults;
                        _dbTrip.PaxMinors = trip.PaxMinors;
                        if (!string.IsNullOrEmpty(trip.Status))
                        {
                            _dbTrip.Status = trip.Status;
                        }
                        if (!string.IsNullOrEmpty(trip.StartLocation))
                        {
                            _dbTrip.StartLocation = trip.StartLocation;
                        }
                        if (!string.IsNullOrEmpty(trip.EndLocation))
                        {
                            _dbTrip.EndLocation = trip.EndLocation;
                        }
                        if (!string.IsNullOrEmpty(trip.Description))
                        {
                            _dbTrip.Description = trip.Description;
                        }

                        await context.SaveChangesAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> SaveDestination(Destination model)
        {
            try
            {
                if (model != null)
                {
                    using (var context = new TravelogyDevEntities1())
                    {
                        if (model.Id == 0)
                        {
                            context.Destinations.Add(model);
                            await context.SaveChangesAsync();
                        }

                        else
                        {
                            var _dbDestinationObj = context.Destinations.Find(model.Id);
                            if (_dbDestinationObj != null)
                            {
                                _dbDestinationObj.Alias               = model.Alias;
                                _dbDestinationObj.BestTimeToVisit     = model.BestTimeToVisit;
                                _dbDestinationObj.Country             = model.Country;
                                _dbDestinationObj.ShortDescription    = model.ShortDescription;
                                _dbDestinationObj.CircuitUrl          = model.CircuitUrl;
                                _dbDestinationObj.Description         = model.Description;
                                _dbDestinationObj.Name                = model.Name;
                                _dbDestinationObj.Tagline             = model.Tagline;
                                _dbDestinationObj.TemplateSearchAlias = model.TemplateSearchAlias;
                                _dbDestinationObj.ThumbnailPath       = model.ThumbnailPath;
                                _dbDestinationObj.TourContinent       = model.TourContinent;
                                _dbDestinationObj.TravelStyles        = model.TravelStyles;
                                _dbDestinationObj.Weightage           = model.Weightage;

                                await context.SaveChangesAsync();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #23
0
        public ActionResult EditTripBookingAccommodation(int id, int tripId = 0)
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var _model  = new AdminTripBookingAccommodationEditModel()
            {
                TripId   = tripId,
                DbObject = context.View_TripBookingAccommodation.Where(p => p.Id == id).FirstOrDefault()
            };

            return(View(_model));
        }
Exemple #24
0
        public ActionResult EditPlace(int id)
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var _model  = context.Places.Find(id);

            if (_model == null)
            {
                throw new ApplicationException("EditPlace: Invalid argument");
            }

            return(View(_model));
        }
Exemple #25
0
        public ActionResult UserDetails(string userId)
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var model   = context.View_User.Where(p => p.Id == userId).FirstOrDefault();

            if (model != null)
            {
                return(View(model));
            }

            throw new ApplicationException("User not found");
        }
Exemple #26
0
        public ActionResult EditDestinationInterest(int destinationInterestId)
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var model   = context.DestinationActivities.Find(destinationInterestId);

            if (model == null)
            {
                throw new ApplicationException("Invalid parameter");
            }

            return(View("AddDestinationInterest", model));
        }
Exemple #27
0
        public static async Task <DomingoBlError> SavePlaceAsync(Place place)
        {
            try
            {
                using (var context = new TravelogyDevEntities1())
                {
                    if (place.Id > 0)
                    {
                        var _dbPlace = context.Places.Find(place.Id);
                        if (_dbPlace == null)
                        {
                            return(new DomingoBlError()
                            {
                                ErrorCode = 100, ErrorMessage = "SavePlaceAsync: No matching record found"
                            });
                        }

                        _dbPlace.CountryId        = place.CountryId;
                        _dbPlace.Activities       = place.Activities;
                        _dbPlace.Attractions      = place.Attractions;
                        _dbPlace.Lattitude        = place.Lattitude;
                        _dbPlace.LongDescription  = place.LongDescription;
                        _dbPlace.Longitude        = place.Longitude;
                        _dbPlace.Name             = place.Name;
                        _dbPlace.ShortDescription = place.ShortDescription;
                        _dbPlace.State            = place.State;

                        await context.SaveChangesAsync();
                    }

                    else
                    {
                        context.Places.Add(place);
                        await context.SaveChangesAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #28
0
        public ActionResult EditSubDestination(int subDestinationId)
        {
            _CheckForAdminAccess();

            var context = new TravelogyDevEntities1();
            var model   = context.SubDestinations.Find(subDestinationId);

            if (model == null)
            {
                throw new ApplicationException("Invalid parameter");
            }

            return(View("AddSubDestination", model));
        }
Exemple #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tm"></param>
        /// <param name="title"></param>
        /// <param name="tripId"></param>
        /// <returns></returns>
        public static DomingoBlError CreateThreadforTrip(ThreadMessage tm, string title, int tripId)
        {
            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    // create the Thread
                    var _thread = new Thread()
                    {
                        AuthorUserId       = tm.TravellerId,
                        CreatedDate        = DateTime.Now,
                        MostRecentPostDate = DateTime.Now,
                        Title        = title,
                        Tags         = "message",
                        AspnetUserId = tm.AspnetUserId
                    };

                    // save it to the DB
                    context.Threads.Add(_thread);
                    context.SaveChanges();

                    // add the message with the ID
                    context.ThreadMessages.Add(tm);
                    tm.ThreadId = _thread.Id;

                    var trip = context.Trips.FirstOrDefault(p => p.Id == tripId);
                    if (trip != null)
                    {
                        trip.ThreadId = _thread.Id;
                    }

                    // commit
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_travellerObj"></param>
        /// <returns></returns>
        public static DomingoBlError UpdateUserTravellerProfile(Traveller _travellerObj)
        {
            try
            {
                using (TravelogyDevEntities1 context = new TravelogyDevEntities1())
                {
                    // look for the profile
                    var _xtravellerObj = context.Travellers.FirstOrDefault(p => p.AspnetUserid == _travellerObj.AspnetUserid);

                    // if it exists, update it
                    if (_xtravellerObj != null)
                    {
                        _xtravellerObj.FirstName       = _travellerObj.FirstName;
                        _xtravellerObj.LastName        = _travellerObj.LastName;
                        _xtravellerObj.Telephone       = _travellerObj.Telephone;
                        _xtravellerObj.Mobile          = _travellerObj.Mobile;
                        _xtravellerObj.AddressLine1    = _travellerObj.AddressLine1;
                        _xtravellerObj.AddressLine2    = _travellerObj.AddressLine2;
                        _xtravellerObj.City            = _travellerObj.City;
                        _xtravellerObj.Country         = _travellerObj.Country;
                        _xtravellerObj.PostCode        = _travellerObj.PostCode;
                        _xtravellerObj.TravelGroupSize = _travellerObj.TravelGroupSize;
                        _xtravellerObj.TravelStyle     = _travellerObj.TravelStyle;
                        _xtravellerObj.TravelInterests = _travellerObj.TravelInterests;
                    }

                    else // create it
                    {
                        context.Travellers.Add(_travellerObj);
                    }

                    // save everything
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }