ActivEarth.DAO.CarpoolDAO.AddCarpool C# (CSharp) Метод

AddCarpool() публичный статический Метод

Adds a new Carpool to the database.
public static AddCarpool ( Carpool carpool, string &errorMessage ) : int
carpool ActivEarth.Objects.Carpool Carpool to add to the database.
errorMessage string
Результат int
        public static int AddCarpool(Carpool carpool, out string errorMessage)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    errorMessage = String.Empty;

                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var carpoolData = new CarpoolDataProvider
                    {
                        start = carpool.Start,
                        destination = carpool.Destination,
                        time = carpool.Time,
                        seats_available = carpool.SeatsAvailable,
                        comments = carpool.Comments,
                        user_id = carpool.UserId
                    };

                    data.CarpoolDataProviders.InsertOnSubmit(carpoolData);
                    data.SubmitChanges();

                    return carpoolData.id;
                }
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
                return 0;
            }
        }