//
        // GET: /Applicant/Create
        public ActionResult Create(int id)
        {
            ViewBag.PositionTitle = db.Positions.Single(a => a.Id == id).Title;
            ViewBag.PositionId = db.Positions.Single(a => a.Id == id).Id;

            Applicant applicant = new Applicant();

            applicant.PositionId = id;

            return View(applicant);
        }
 //
 // GET: /Applicant/Delete/5
 public ActionResult Delete(int id, Applicant collection)
 {
     var PositionId = db.Positions.Single(a => a.Applicant.Where(b => b.Id == id).Any()).Id;
     collection = db.Applicants.Single(a => a.Id == id);
     if (ModelState.IsValid)
     {
         db.DeleteObject(collection);
         db.SaveChanges();
         return RedirectToAction("Index", new { id = PositionId });
     }
     else
     {
         return View();
     }
 }
        public ActionResult Create(int id, Applicant collection)
        {
            if (ModelState.IsValid)
            {
                // TODO: Add insert logic here
                db.Applicants.AddObject(collection);
                db.SaveChanges();

                return RedirectToAction("Index", new { id = collection.PositionId });
            }
            else
            {
                return View(collection);
            }
        }
 /// <summary>
 /// Create a new Applicant object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="major">Initial value of the Major property.</param>
 /// <param name="school">Initial value of the School property.</param>
 /// <param name="positionId">Initial value of the PositionId property.</param>
 public static Applicant CreateApplicant(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String major, global::System.String school, global::System.Int32 positionId)
 {
     Applicant applicant = new Applicant();
     applicant.Id = id;
     applicant.FirstName = firstName;
     applicant.LastName = lastName;
     applicant.Major = major;
     applicant.School = school;
     applicant.PositionId = positionId;
     return applicant;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Applicants EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToApplicants(Applicant applicant)
 {
     base.AddObject("Applicants", applicant);
 }
        public ActionResult Edit(int id, Applicant collection)
        {
            collection = db.Applicants.Single(a => a.Id == id);
            try
            {
                UpdateModel(collection);
                db.SaveChanges();

                return RedirectToAction("Details", new { id = id });
            }
            catch
            {
                return View(collection);
            }
        }
        public ActionResult Promote(int id, Position collection, Applicant applicant)
        {
            var PositionId = db.Positions.Single(a => a.Applicant.Where(b => b.Id == id).Any()).Id;

            applicant = db.Applicants.Single(a => a.Id == id);
            collection = db.Positions.Single(a => a.Id == PositionId);

            if (ModelState.IsValid)
            {
                collection.ActiveNow = false;
                UpdateModel(applicant);
                db.SaveChanges();

                return RedirectToAction("Index", "Position");
            }
            else
            {
                return View(collection);
            }
        }