ActivEarth.DAO.ContestDAO.CreateNewContest C# (CSharp) Метод

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

Saves a contest as a new entry in the DB.
public static CreateNewContest ( Contest contest ) : int
contest ActivEarth.Objects.Competition.Contests.Contest Contest object to add to the DB.
Результат int
        public static int CreateNewContest(Contest contest)
        {
            try
            {
                int id;

                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var contestData = new ContestDataProvider
                    {
                        name = contest.Name,
                        description = contest.Description,
                        reward = contest.Reward,
                        end_mode = (byte)contest.Mode,
                        end_goal = contest.EndValue,
                        end_time = contest.EndTime,
                        start = contest.StartTime,
                        type = (byte)contest.Type,
                        statistic = (byte)contest.StatisticBinding,
                        searchable = contest.IsSearchable,
                        active = contest.IsActive,
                        deactivated = contest.DeactivatedTime,
                        creator_id = contest.CreatorId
                    };
                    data.ContestDataProviders.InsertOnSubmit(contestData);
                    data.SubmitChanges();

                    id = contestData.id;
                }

                foreach (ContestTeam team in contest.Teams)
                {
                    TeamDAO.CreateNewTeam(team);
                }

                return id;
            }
            catch (Exception)
            {
                return 0;
            }
        }