public ActionResult Create(Position collection)
        {
            ViewBag.Department = new SelectList(db.Departments, "Id", "Name");

            try
            {
                collection.DateAdded = DateTime.Now;
                collection.AddedBy = "Alex Riabov";
                collection.ActiveNow = true;

                db.Positions.AddObject(collection);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {

                return View(collection);
            }
            //catch
            //{
            //    return View();
            //}
        }
 public ActionResult Delete(int id, Position collection)
 {
     collection = db.Positions.Single(a => a.Id == id);
     if (ModelState.IsValid)
     {
         db.DeleteObject(collection);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }
        public ActionResult Edit(int id, Position collection)
        {
            ViewBag.Department = new SelectList(db.Departments, "Id", "Name");

            collection = db.Positions.Single(a => a.Id == id);
            if (ModelState.IsValid)
            {
                UpdateModel(collection);
                db.SaveChanges();

                return RedirectToAction("Details", new { id = id });
            }
            else
            {

                return View(collection);
            }
        }
 /// <summary>
 /// Create a new Position object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="departmentId">Initial value of the DepartmentId property.</param>
 /// <param name="closeDate">Initial value of the CloseDate property.</param>
 public static Position CreatePosition(global::System.Int32 id, global::System.String title, global::System.Int32 departmentId, global::System.DateTime closeDate)
 {
     Position position = new Position();
     position.Id = id;
     position.Title = title;
     position.DepartmentId = departmentId;
     position.CloseDate = closeDate;
     return position;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Positions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPositions(Position position)
 {
     base.AddObject("Positions", position);
 }
        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);
            }
        }