Example #1
0
        public static void AddNewCompetition(Models.CompetitionModel model)
        {
            Competition comp = new Competition();
            comp.CategoryId = model.CategoryId;
            comp.Start = model.Start;
            comp.End = model.End;
            comp.Duration = model.Duration;
            comp.Name = model.Name;
            comp.Description = model.Description;

            using (TopCoderPrototypeEntities entityModel = new TopCoderPrototypeEntities())
            {
                entityModel.AddToCompetitions(comp);
                entityModel.SaveChanges();
                if (model.SelectedProblems != null)
                {
                    foreach (var problem in model.SelectedProblems)
                    {
                        CompetetionsProblem cp = new CompetetionsProblem();
                        cp.CompetetionId = comp.ID;
                        cp.ProblemId = problem;
                        entityModel.CompetetionsProblems.AddObject(cp);
                    }
                    entityModel.SaveChanges();
                }
            }
        }
 /// <summary>
 /// Create a new Competition object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="categoryId">Initial value of the CategoryId property.</param>
 /// <param name="start">Initial value of the Start property.</param>
 /// <param name="end">Initial value of the End property.</param>
 /// <param name="duration">Initial value of the Duration property.</param>
 public static Competition CreateCompetition(global::System.Int32 id, global::System.String name, global::System.Int32 categoryId, global::System.DateTime start, global::System.DateTime end, global::System.Int32 duration)
 {
     Competition competition = new Competition();
     competition.ID = id;
     competition.Name = name;
     competition.CategoryId = categoryId;
     competition.Start = start;
     competition.End = end;
     competition.Duration = duration;
     return competition;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Competitions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCompetitions(Competition competition)
 {
     base.AddObject("Competitions", competition);
 }