Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
Beispiel #1
0
        /// <summary>
        /// Saves a contest as a new entry in the DB.
        /// </summary>
        /// <param name="contest">Contest object to add to the DB.</param>
        /// <returns>ID of the created contest on success, 0 on failure.</returns>
        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,
                        points = contest.Points,
                        end_mode = (byte)contest.Mode,
                        end_goal = contest.EndCondition.EndValue,
                        end_time = contest.EndCondition.EndTime,
                        start = contest.StartTime,
                        type = (byte)contest.Type,
                        statistic = (byte)contest.StatisticBinding,
                    };
                    data.ContestDataProviders.InsertOnSubmit(contestData);
                    data.SubmitChanges();

                    id = contestData.id;
                }

                foreach (Team team in contest.Teams)
                {
                    //TeamDAO.CreateNewTeam(team, contest.ID);
                }

                return id;
            }
            catch (Exception)
            {
                return 0;
            }
        }
		private void detach_ContestDataProviders(ContestDataProvider entity)
		{
			this.SendPropertyChanging();
			entity.UserDataProvider = null;
		}
 partial void DeleteContestDataProvider(ContestDataProvider instance);
 partial void UpdateContestDataProvider(ContestDataProvider instance);
 partial void InsertContestDataProvider(ContestDataProvider instance);
Beispiel #6
0
        /// <summary>
        /// Saves a contest as a new entry in the DB.
        /// </summary>
        /// <param name="contest">Contest object to add to the DB.</param>
        /// <returns>ID of the created contest on success, 0 on failure.</returns>
        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;
            }
        }