public ActionResult Create(int itm)
        {
            Request request = new Request();
            Item item = db.Items.Single(i => i.id == itm);
            request.requestor_id = ShareThings.Content.SessionThings.LoggedInUser.id;
            request.location_id = item.User.location_id;
            request.item_id = item.id;
            request.itemWant = item.name;
            request.dateRequested = DateTime.Now;
            request.dateRecieved = DateTime.Now;
            request.dateReturned = DateTime.Now;
            request.dateWantedReturn = DateTime.Now;
            request.isAccepted = false;
            request.isCheckedOut = false;

            try
            {
                db.Requests.AddObject(request);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                ViewBag.item_id = new SelectList(db.Items, "id", "name", request.item_id);
                ViewBag.requestor_id = new SelectList(db.Users, "id", "email", request.requestor_id);
                ViewBag.location_id = new SelectList(db.Locations, "id", "name", request.location_id);
                ViewBag.TopCategories = new List<Category>(db.Categories.Where(c => c.parent_id == -1));
                return View(request);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Requests EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRequests(Request request)
 {
     base.AddObject("Requests", request);
 }
 public ActionResult Edit(Request request)
 {
     if (ModelState.IsValid)
     {
         db.Requests.Attach(request);
         db.ObjectStateManager.ChangeObjectState(request, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.item_id = new SelectList(db.Items, "id", "name", request.item_id);
     ViewBag.requestor_id = new SelectList(db.Users, "id", "email", request.requestor_id);
     ViewBag.location_id = new SelectList(db.Locations, "id", "name", request.location_id);
     return View(request);
 }
 /// <summary>
 /// Create a new Request object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="requestor_id">Initial value of the requestor_id property.</param>
 /// <param name="item_id">Initial value of the item_id property.</param>
 /// <param name="isAccepted">Initial value of the isAccepted property.</param>
 /// <param name="location_id">Initial value of the location_id property.</param>
 /// <param name="isCheckedOut">Initial value of the isCheckedOut property.</param>
 /// <param name="dateRequested">Initial value of the dateRequested property.</param>
 /// <param name="dateRecieved">Initial value of the dateRecieved property.</param>
 /// <param name="dateReturned">Initial value of the dateReturned property.</param>
 /// <param name="dateWantedReturn">Initial value of the dateWantedReturn property.</param>
 /// <param name="giverRating">Initial value of the giverRating property.</param>
 /// <param name="recieverRating">Initial value of the recieverRating property.</param>
 public static Request CreateRequest(global::System.Int32 id, global::System.Int32 requestor_id, global::System.Int32 item_id, global::System.Boolean isAccepted, global::System.Int32 location_id, global::System.Boolean isCheckedOut, global::System.DateTime dateRequested, global::System.DateTime dateRecieved, global::System.DateTime dateReturned, global::System.DateTime dateWantedReturn, global::System.Int32 giverRating, global::System.Int32 recieverRating)
 {
     Request request = new Request();
     request.id = id;
     request.requestor_id = requestor_id;
     request.item_id = item_id;
     request.isAccepted = isAccepted;
     request.location_id = location_id;
     request.isCheckedOut = isCheckedOut;
     request.dateRequested = dateRequested;
     request.dateRecieved = dateRecieved;
     request.dateReturned = dateReturned;
     request.dateWantedReturn = dateWantedReturn;
     request.giverRating = giverRating;
     request.recieverRating = recieverRating;
     return request;
 }