public void SetDropDowns(SalesOrder user)
 {
     ViewBag.Manager = new SelectList(dbUser.GetAllUsers, "ID", "Fullname", user.Manager.ID);
     ViewBag.BusinessUnit = new SelectList(dbOrg.Fetch, "ID", "Name", user.Organization.ID);
     ViewBag.Team = new SelectList(dbTeam.Fetch, "ID", "Name", user.Team.ID);
 }
 public ActionResult Edit(SalesOrder updatedData, int id)
 {
     SetDropDowns(updatedData);
     db.Update(updatedData, id);
     return RedirectToAction("Index");
 }
 public ActionResult Create(SalesOrder newData)
 {
     CreateDropDowns();
     db.Insert(newData);
     return RedirectToAction("Index");
 }
        // sets parameters for insert/update
        private Dictionary<string, object> SetParams(SalesOrder data)
        {
            Dictionary<string, object> result = new Dictionary<string, object>();

            result.Add("@name", data.Name);
            result.Add("@managerid", data.Manager.ID);
            result.Add("@businessunitid", data.Organization.ID);
            result.Add("@positionID", data.Team.ID);
            result.Add("@status", data.Status);

            return result;
        }
 public void Update(SalesOrder data, int id)
 {
     ExecuteNonQuery(QueryBuilder.Update(_tableName, TargetFields, id, _pkField), SetParams(data));
 }
 public void Insert(SalesOrder data)
 {
     ExecuteNonQuery(QueryBuilder.Insert(_tableName, TargetFields), SetParams(data));
 }