/// <summary>
 /// Deprecated Method for adding a new object to the results EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToresults(result result)
 {
     base.AddObject("results", result);
 }
        public ActionResult saveResult(FormCollection c)
        {
            if (Session["id"] == null)
                return RedirectToAction("signin", "Home");
            for (int i = 0; i < c.Count; i++)
            {
                result obj = new result();

                string str = c.GetKey(i);
                var res = str.Split(';');
                obj.studentId = Convert.ToInt32(res[0]);
                obj.csId = Convert.ToInt32(res[1]);
                obj.examId = Convert.ToInt32(res[2]);
                //     obj.obtainedMarks = Convert.ToInt32(c[str]);
                if (c[str] != null)
                {
                    try
                    {
                        obj.obtainedMarks = Convert.ToInt32(c[str]);
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                    result lbl = null;
                    try
                    {
                        lbl = (from sub in db.results where sub.studentId == obj.studentId && sub.examId == obj.examId && sub.csId == obj.csId select sub).First();
                    }
                    catch (Exception e)
                    { }
                    if (lbl != null)
                    {
                        if (obj.obtainedMarks == lbl.obtainedMarks)
                        {

                        }
                        else
                        {
                            lbl.obtainedMarks = obj.obtainedMarks;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        db.results.AddObject(obj);
                        db.SaveChanges();
                    }
                }
                else
                { }

            }
            TempData["response"] = "Result Updated Successfully...";
            return RedirectToAction("ResultIndex");
        }
 /// <summary>
 /// Create a new result object.
 /// </summary>
 /// <param name="examId">Initial value of the examId property.</param>
 /// <param name="studentId">Initial value of the studentId property.</param>
 /// <param name="csId">Initial value of the csId property.</param>
 /// <param name="obtainedMarks">Initial value of the obtainedMarks property.</param>
 public static result Createresult(global::System.Int32 examId, global::System.Int32 studentId, global::System.Int32 csId, global::System.Int32 obtainedMarks)
 {
     result result = new result();
     result.examId = examId;
     result.studentId = studentId;
     result.csId = csId;
     result.obtainedMarks = obtainedMarks;
     return result;
 }