Example #1
0
        public static void AddNewProblem(ProblemModel model, int? id, ProblemType type)
        {
            using (TopCoderPrototypeEntities entityModel = new TopCoderPrototypeEntities())
            {
                Problem problem = new Problem();
                problem.Title = model.Title;
                problem.ProblemType = (int)type;

                BinaryFormatter bf = new BinaryFormatter();
                MemoryStream ms = new MemoryStream();
                bf.Serialize(ms, model);
                problem.Data = ms.ToArray();

                entityModel.AddToProblems(problem);
                entityModel.SaveChanges();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Problems EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProblems(Problem problem)
 {
     base.AddObject("Problems", problem);
 }
 /// <summary>
 /// Create a new Problem object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="problemType">Initial value of the ProblemType property.</param>
 /// <param name="authorId">Initial value of the AuthorId property.</param>
 /// <param name="data">Initial value of the Data property.</param>
 public static Problem CreateProblem(global::System.Int32 id, global::System.String title, global::System.Int32 problemType, global::System.Int32 authorId, global::System.Byte[] data)
 {
     Problem problem = new Problem();
     problem.ID = id;
     problem.Title = title;
     problem.ProblemType = problemType;
     problem.AuthorId = authorId;
     problem.Data = data;
     return problem;
 }