ActivEarth.DAO.RecyclingDAO.AddRecycleCenter C# (CSharp) Метод

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

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

                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var centerData = new RecyclingCenterDataProvider
                    {
                        location = center.Location,
                        comments = center.Comments,
                        automotive = center.Automotive,
                        electronics = center.Electronics,
                        construction = center.Construction,
                        batteries = center.Batteries,
                        garden = center.Garden,
                        glass = center.Glass,
                        hazardous = center.Hazardous,
                        household = center.Household,
                        metal = center.Metal,
                        paint = center.Paint,
                        paper = center.Paper,
                        plastic = center.Plastic,
                        user_id = center.UserId
                    };

                    data.RecyclingCenterDataProviders.InsertOnSubmit(centerData);
                    data.SubmitChanges();

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