Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
示例#1
0
        /// <summary>
        /// Adds a new Route to the database.
        /// </summary>
        /// <param name="route">Route to add to the database.</param>
        /// <returns>Primary Key (ID) of the newly added Route.</returns>
        public static int AddNewRoute(Route route, out string errorMessage)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    errorMessage = String.Empty;

                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var routeData = new ActiveRouteDataProvider
                    {
                        gmt_offset = route.GMTOffset,
                        distance = route.Distance,
                        end_latitude = route.EndLatitude,
                        end_longitude = route.EndLongitude,
                        end_time = route.EndTime,
                        mode = route.Mode,
                        points = route.Points,
                        start_latitude = route.StartLatitude,
                        start_longitude = route.StartLongitude,
                        start_time = route.StartTime,
                        steps = route.Steps,
                        type = route.Type,
                        user_id = route.UserId
                    };

                    data.ActiveRouteDataProviders.InsertOnSubmit(routeData);
                    data.SubmitChanges();

                    if (routeData.id > 0)
                    {
                        ActiveRouteDAO.ProcessRoute(route);
                    }

                    return routeData.id;
                }
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
                return 0;
            }
        }
 partial void DeleteActiveRouteDataProvider(ActiveRouteDataProvider instance);
 partial void UpdateActiveRouteDataProvider(ActiveRouteDataProvider instance);
 partial void InsertActiveRouteDataProvider(ActiveRouteDataProvider instance);
		private void detach_ActiveRouteDataProviders(ActiveRouteDataProvider entity)
		{
			this.SendPropertyChanging();
			entity.UserDataProvider = null;
		}