Esempio n. 1
0
        public ActionResult TrackingDetails(string trackingId)
        {
            try
            {
                ObjectId id = ObjectId.Parse(trackingId);

                Tracking           t            = _trackingCollection.AsQueryable().FirstOrDefault(x => x.Id == id);
                TrackableItem      ti           = _trackableItemsCollection.AsQueryable().FirstOrDefault(x => x.Id == t.TrackingItemId);
                TrackableItemState currentState = ti.States.FirstOrDefault(state => state.Id == t.StateId);

                ViewBag.StateNames = new Dictionary <string, string>();
                ti.States.ToList().ForEach(s => ((Dictionary <string, string>)ViewBag.StateNames).Add(s.Id.ToString(), s.Name));


                SearchTrackingInfo si = new SearchTrackingInfo();
                si.QrData                      = QRCodeHtmlHelper.CreateQrData(t.Id.ToString(), t.Password);
                si.TrackingName                = t.Id.ToString();
                si.TrackabeItemName            = ti.Name;
                si.State                       = currentState.Name;
                si.History                     = t.History;
                si.SupportsGeolocationServices = ti.SupportsGeolocationServices;

                return(View(si));
            }
            catch (Exception)
            {
                return(new HttpNotFoundResult("The tracking with a specified tracking number doesn't exist"));
            }
        }
Esempio n. 2
0
 public TrackableItemViewModel(TrackableItem ti)
 {
     _dataSource        = ti;
     AddStateCommand    = new DelegateCommand(AddState, x => true);
     EditStateCommand   = new DelegateCommand(EditState, x => _selectedState != null);
     RemoveStateCommand = new DelegateCommand(RemoveState, x => _selectedState != null);
 }
Esempio n. 3
0
        public TrackableItem UpdateTrackableItem(string sessionId, TrackableItem clientTrackableItem)
        {
            if (!ValidateUser(sessionId))
            {
                throw new Exception("Not authorized");
            }
            ObjectId clietTiId;

            if (!ObjectId.TryParse(clientTrackableItem.Id, out clietTiId))
            {
                throw  new Exception("Invalid Trackable Item ID");
            }

            string userId   = GetUser(sessionId);
            var    serverTi =
                _trackableItemsCollection.AsQueryable()
                .FirstOrDefault(
                    x =>
                    x.Id == clietTiId && x.UserId == userId);

            if (serverTi == null)
            {
                throw new Exception("TrackableItem with specified id not found in the database");
            }

            if (serverTi.States == null)
            {
                serverTi.States = new List <ServerDataModel.TrackableItemState>();
            }
            clientTrackableItem.States.ToList().ForEach(cst =>
            {
                //if server entity doesnt contain any client entity - add entity for server.
                //however if it is and client's one has an ID set - generate error.
                if (serverTi.States.FirstOrDefault(ss => ss.Id.ToString() == cst.Id) == null)
                {
                    if (string.IsNullOrEmpty(cst.Id))
                    {
                        ServerDataModel.TrackableItemState sState = new ServerDataModel.TrackableItemState()
                        {
                            Id = ObjectId.GenerateNewId()
                        };
                        serverTi.States.Add(sState);
                        cst.Id = sState.Id.ToString();
                    }
                    else
                    {
                        throw new Exception(string.Format("The state with id {0} wasn't found for trackable item {1}. In case adding new state leave the Id field empty.", cst.Id, clientTrackableItem.Id));
                    }
                }
            });

            //Applying client data
            serverTi.ApplyClientData(clientTrackableItem);
            _trackableItemsCollection.Save(serverTi);

            //return a result to user
            return(serverTi.ToClientData <TrackableItem>());
        }
Esempio n. 4
0
        public ActionResult Index(SearchTracking st)
        {
            try
            {
                ObjectId id;
                if (ObjectId.TryParse(st.TrackingNumber, out id))
                {
                    //try ti search in db
                    Tracking t = _trackingCollection.AsQueryable().FirstOrDefault(x => x.Id == id);
                    if (t != null)
                    {
                        if (string.IsNullOrEmpty(t.Password) ||
                            (!string.IsNullOrWhiteSpace(st.Password) && !string.IsNullOrEmpty(t.Password) &&
                             string.Equals(st.Password, t.Password)))
                        {
                            //found and unsecured or password is OK:

                            SearchTrackingInfo si = new SearchTrackingInfo();
                            si.QrData = QRCodeHtmlHelper.CreateQrData(t.Id.ToString(), t.Password);
                            TrackableItem ti =
                                _trackableItemsCollection.AsQueryable().FirstOrDefault(x => x.Id == t.TrackingItemId);
                            TrackableItemState currentState = ti.States.FirstOrDefault(state => state.Id == t.StateId);
                            si.TrackingName                = t.Id.ToString();
                            si.TrackabeItemName            = ti.Name;
                            si.State                       = currentState.Name;
                            si.History                     = t.History;
                            si.SupportsGeolocationServices = ti.SupportsGeolocationServices;
                            ViewBag.StateNames             = new Dictionary <string, string>();
                            ti.States.ToList()
                            .ForEach(
                                s => ((Dictionary <string, string>)ViewBag.StateNames).Add(s.Id.ToString(), s.Name));
                            return(View("TrackingDetails", si));
                            //return RedirectToAction("TrackingDetails", new {trackingId = st.TrackingNumber});
                        }
                        else
                        {
                            //need password
                            ViewBag.PasswordRequired = true;
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", Resource.PublicTrackingController_Index_The_item_with_speficied_number_wasn_t_found_in_our_system__Please_verify_your_input_);
                    }
                }
                else
                {
                    ModelState.AddModelError("TrackingNumber", Resource.PublicTrackingController_Index_Incorrect_tracking_number__Please_verify_your_input_);
                    //incorrect tracking number
                }
            }
            catch
            {
                return(View());
            }
            return(View());
        }
 private static Brake CreateBrake(TrackableItem bicycle)
 {
     return(new Brake(bicycle)
     {
         Make = "Shimano",
         Model = "Center pull",
         SerialNumber = "123A456B",
         Cost = 50.00m
     });
 }
 public ActionResult Delete(ObjectId id, TrackableItem ti)
 {
     try
     {
         var item = _trackableItemsCollection.Remove(Query <TrackableItem> .EQ(x => x.Id, id));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 7
0
        public static string GetTrackedItemsStatsMenuName(TrackableItem item)
        {
            foreach (TrackedItemStatsMenu trackedItem in TrackedItemsStatsMenu)
            {
                if (trackedItem.What == item.ToString())
                {
                    return(trackedItem.Value);
                }
            }

            throw new KeyNotFoundException("no such tracked item found.");
        }
 private static Light CreateLight(TrackableItem bicycle)
 {
     return(new Light(bicycle)
     {
         Make = "Cree",
         Model = "Multifunction",
         SerialNumber = "123",
         Cost = 31.99m,
         BatteryType = "Lithium Ion",
         LightBulb = "LED",
     });
 }
Esempio n. 9
0
        public Tracking(User user)
        {
            baseUser = user;

            for (int i = 0; i < 20; i++)
            {
                TrackableItem item = (TrackableItem)i;
                if (Database.HasTrackedItem(user.Id, item))
                {
                    TrackedItem trackedItem = new TrackedItem(baseUser, item, Database.GetTrackedCount(user.Id, item));
                    trackingItems.Add(trackedItem);
                }
            }
        }
 public ActionResult Create(TrackableItem ti)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ti.UserId = User.Identity.Name;
             _trackableItemsCollection.Insert(ti);
         }
         // TODO: Add insert logic here
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Esempio n. 11
0
        public TrackedItem GetTrackedItem(TrackableItem what)
        {
            foreach (TrackedItem trackedItem in TrackingItems)
            {
                if (trackedItem.What == what)
                {
                    return(trackedItem);
                }
            }

            // if it doesnt exist- create it
            TrackedItem item = new TrackedItem(baseUser, what, 0);

            Database.AddTrackedItem(baseUser.Id, what, 0);
            trackingItems.Add(item);
            return(item);
        }
 public ActionResult Create(TrackableItem ti)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ti.UserId = User.Identity.Name;
             _trackableItemsCollection.Insert(ti);
         }
         // TODO: Add insert logic here
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(ObjectId id, TrackableItem ti)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var oldItem = _trackableItemsCollection.AsQueryable().FirstOrDefault(x => x.Id == id);
             ti.States = oldItem.States;
             _trackableItemsCollection.Save(ti);
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 14
0
 public Light(TrackableItem bicycle) : base(bicycle)
 {
 }
Esempio n. 15
0
 private TrackableItem GetTrackableItemFromLiveAPI(Utils.API.LiveV6.Trackable t)
 {
     TrackableItem trk = new TrackableItem();
     trk.Code = t.Code;
     trk.AllowedToBeCollected = t.AllowedToBeCollected;
     trk.Archived = t.Archived;
     trk.BugTypeID = t.BugTypeID;
     trk.CurrentGeocacheCode = t.CurrentGeocacheCode;
     trk.CurrentGoal = t.CurrentGoal;
     trk.DateCreated = t.DateCreated;
     trk.Description = t.Description;
     trk.IconUrl = t.IconUrl;
     trk.Id = t.Id;
     trk.InCollection = t.InCollection;
     trk.Name = t.Name;
     trk.TBTypeName = t.TBTypeName;
     trk.Url = t.Url;
     trk.WptTypeID = t.WptTypeID;
     if (t.OriginalOwner != null)
     {
         trk.Owner = t.OriginalOwner.UserName;
     }
     else
     {
         trk.Owner = "";
     }
     return trk;
 }
Esempio n. 16
0
        private void AddTrackableToDatabase(TrackableItem t)
        {
            if (!string.IsNullOrEmpty(t.IconUrl))
            {
                DbParameter par;

                long cnt = (long)_dbcon.ExecuteScalar(string.Format("select count(1) from images where url='{0}'", t.IconUrl));
                if (cnt == 0)
                {
                    try
                    {
                        using (System.Net.WebClient wc = new System.Net.WebClient())
                        {
                            byte[] data = wc.DownloadData(t.IconUrl);
                            if (data != null)
                            {
                                _dbcon.Command.Parameters.Clear();
                                par = _dbcon.Command.CreateParameter();
                                par.ParameterName = "@data";
                                par.DbType = DbType.Binary;
                                par.Value = data;
                                _dbcon.Command.Parameters.Add(par);
                                _dbcon.ExecuteNonQuery(string.Format("insert into images (url, imagedata) values ('{0}', @data)", t.IconUrl));
                                _dbcon.Command.Parameters.Clear();
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                _dbcon.Command.Parameters.Clear();
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@groupid";
                par.DbType = DbType.Int32;
                par.Value = _activeTrackableGroup.ID;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@AllowedToBeCollected";
                par.DbType = DbType.Int32;
                if (t.AllowedToBeCollected == null)
                {
                    par.Value = DBNull.Value;
                }
                else
                {
                    par.Value = t.AllowedToBeCollected == true ? 1 : 0;
                }
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Archived";
                par.DbType = DbType.Int32;
                par.Value = t.Archived?1:0;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@BugTypeID";
                par.DbType = DbType.Int32;
                par.Value = t.BugTypeID;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Code";
                par.DbType = DbType.String;
                par.Value = t.Code;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@CurrentGeocacheCode";
                par.DbType = DbType.String;
                par.Value = t.CurrentGeocacheCode??"";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@CurrentGoal";
                par.DbType = DbType.String;
                par.Value = t.CurrentGoal ?? "";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@DateCreated";
                par.DbType = DbType.String;
                par.Value = t.DateCreated.ToString("u");
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Description";
                par.DbType = DbType.String;
                par.Value = t.Description??"";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@IconUrl";
                par.DbType = DbType.String;
                par.Value = t.IconUrl ?? "";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Id";
                par.DbType = DbType.Int32;
                par.Value = t.Id;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@InCollection";
                par.DbType = DbType.Int32;
                par.Value = t.InCollection?1:0;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Name";
                par.DbType = DbType.String;
                par.Value = t.Name ?? "";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@TBTypeName";
                par.DbType = DbType.String;
                par.Value = t.TBTypeName ?? "";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Url";
                par.DbType = DbType.String;
                par.Value = t.Url ?? "";
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@WptTypeID";
                par.DbType = DbType.Int32;
                par.Value = t.WptTypeID;
                _dbcon.Command.Parameters.Add(par);
                par = _dbcon.Command.CreateParameter();
                par.ParameterName = "@Owner";
                par.DbType = DbType.String;
                par.Value = t.Owner ?? "";
                _dbcon.Command.Parameters.Add(par);

                if (_dbcon.ExecuteNonQuery("update trackables set AllowedToBeCollected=@AllowedToBeCollected, Archived=@Archived, BugTypeID=@BugTypeID, CurrentGeocacheCode=@CurrentGeocacheCode, CurrentGoal=@CurrentGoal, DateCreated=@DateCreated, Description=@Description, IconUrl=@IconUrl, Id=@Id, InCollection=@InCollection, Name=@Name, TBTypeName=@TBTypeName, Url=@Url, WptTypeID=@WptTypeID, Owner=@Owner where groupid=@groupid and Code=@Code") == 0)
                {
                    _dbcon.ExecuteNonQuery("insert into trackables (groupid, AllowedToBeCollected, Archived, BugTypeID, Code, CurrentGeocacheCode, CurrentGoal, DateCreated, Description, IconUrl, Id, InCollection, Name, TBTypeName, Url, WptTypeID, Owner) values (@groupid, @AllowedToBeCollected, @Archived, @BugTypeID, @Code, @CurrentGeocacheCode, @CurrentGoal, @DateCreated, @Description, @IconUrl, @Id, @InCollection, @Name, @TBTypeName, @Url, @WptTypeID, @Owner)");
                }
                _dbcon.Command.Parameters.Clear();
            }
        }
Esempio n. 17
0
        private void comboBoxGroup_SelectedValueChanged(object sender, EventArgs e)
        {
            TrackableGroup tg = comboBoxGroup.SelectedItem as TrackableGroup;
            _activeTrackableGroup = tg;
            listView1.Items.Clear();
            if (tg == null)
            {
                buttonGroupDelete.Enabled = false;
                buttonGroupRename.Enabled = false;
                buttonAddYouOwn.Enabled = false;
                buttonAddTrackables.Enabled = false;
                textBoxTBCodes.Enabled = false;
                showAllOnMapToolStripMenuItem.Enabled = false;
                updateAllTrackablesInGroupToolStripMenuItem.Enabled = false;
                textBoxGroupName.Text = "";
            }
            else
            {
                buttonGroupDelete.Enabled = true;
                buttonGroupRename.Enabled = true;
                buttonAddYouOwn.Enabled = true;
                textBoxTBCodes.Enabled = true;
                updateAllTrackablesInGroupToolStripMenuItem.Enabled = true;
                showAllOnMapToolStripMenuItem.Enabled = true;
                textBoxGroupName.Text = tg.Name;
                textBoxTBCodes_TextChanged(sender, e);

                listView1.BeginUpdate();
                try
                {
                    DbDataReader dr = _dbcon.ExecuteReader(string.Format("select * from trackables where groupid={0}", tg.ID));
                    while (dr.Read())
                    {
                        TrackableItem trk = new TrackableItem();
                        trk.Code = (string)dr["Code"];
                        if (dr["AllowedToBeCollected"] != null && dr["AllowedToBeCollected"].GetType() != typeof(DBNull))
                        {
                            trk.AllowedToBeCollected = (int)dr["AllowedToBeCollected"]!=0;
                        }
                        else
                        {
                            trk.AllowedToBeCollected = null;
                        }
                        trk.Archived = (int)dr["Archived"] != 0;
                        trk.BugTypeID = (int)dr["BugTypeID"];
                        trk.CurrentGeocacheCode = (string)dr["CurrentGeocacheCode"];
                        trk.CurrentGoal = (string)dr["CurrentGoal"];
                        trk.DateCreated = DateTime.Parse((string)dr["DateCreated"]);
                        trk.Description = (string)dr["Description"];
                        trk.IconUrl = (string)dr["IconUrl"];
                        trk.Id = (int)dr["Id"];
                        trk.InCollection = (int)dr["InCollection"] != 0;
                        trk.Name = (string)dr["Name"];
                        trk.TBTypeName = (string)dr["TBTypeName"];
                        trk.Url = (string)dr["Url"];
                        trk.WptTypeID = (int)dr["WptTypeID"];
                        trk.Owner = (string)dr["Owner"];

                        if (dr["HopCount"] != null && dr["HopCount"].GetType() != typeof(DBNull))
                        {
                            trk.HopCount = (int)dr["HopCount"];
                        }
                        else
                        {
                            trk.HopCount = 0;
                        }
                        if (dr["DiscoverCount"] != null && dr["DiscoverCount"].GetType() != typeof(DBNull))
                        {
                            trk.DiscoverCount = (int)dr["DiscoverCount"];
                        }
                        else
                        {
                            trk.DiscoverCount = 0;
                        }
                        if (dr["InCacheCount"] != null && dr["InCacheCount"].GetType() != typeof(DBNull))
                        {
                            trk.InCacheCount = (int)dr["InCacheCount"];
                        }
                        else
                        {
                            trk.InCacheCount = 0;
                        }
                        if (dr["DistanceKm"] != null && dr["DistanceKm"].GetType() != typeof(DBNull))
                        {
                            trk.DistanceKm = (double)dr["DistanceKm"];
                        }
                        else
                        {
                            trk.DistanceKm = 0.0;
                        }
                        if (dr["Lat"] != null && dr["Lat"].GetType() != typeof(DBNull))
                        {
                            trk.Lat = (double)dr["Lat"];
                        }
                        else
                        {
                            trk.Lat = null;
                        }
                        if (dr["Lon"] != null && dr["Lon"].GetType() != typeof(DBNull))
                        {
                            trk.Lon = (double)dr["Lon"];
                        }
                        else
                        {
                            trk.Lon = null;
                        }

                        ListViewItem lv = new ListViewItem(new string[] { trk.IconUrl, trk.Code, trk.Name, trk.Owner, trk.CurrentGeocacheCode, trk.HopCount.ToString().PadLeft(5), trk.InCacheCount.ToString().PadLeft(5), trk.DiscoverCount.ToString().PadLeft(5), trk.DistanceKm.ToString("0.0").PadLeft(9) }, trk.IconUrl);
                        lv.Tag = trk;
                        listView1.Items.Add(lv);
                    }
                }
                catch
                {
                }
                listView1.EndUpdate();
            }
        }
Esempio n. 18
0
        private void ShowRouteOnMap(TrackableItem tb)
        {
            if (tb != null)
            {
                try
                {
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.TrkGroup.trackablesmap.html")))
                    {
                        string htmlcontent = textStreamReader.ReadToEnd();
                        StringBuilder sb = new StringBuilder();
                        List<TravelItem> til = new List<TravelItem>();
                        DbDataReader dr = _dbcon.ExecuteReader(string.Format("select GeocacheCode, lat, lon, DateLogged from travels where TrackableCode='{0}' order by pos", tb.Code));
                        while (dr.Read())
                        {
                            TravelItem ti = new TravelItem();
                            ti.DateLogged = DateTime.Parse((string)dr["DateLogged"]);
                            ti.GeocacheCode = (string)dr["GeocacheCode"];
                            ti.Lat = (double)dr["lat"];
                            ti.Lon = (double)dr["lon"];
                            til.Add(ti);
                        }
                        for (int i=0; i<til.Count; i++)
                        {
                            StringBuilder bln = new StringBuilder();
                            bln.AppendFormat("{0}: {1}", Utils.LanguageSupport.Instance.GetTranslation(STR_STEP), i + 1);
                            bln.AppendFormat("<br />{0}: {1}", Utils.LanguageSupport.Instance.GetTranslation(STR_DATE), til[i].DateLogged.ToLongDateString());
                            bln.AppendFormat("<br />{0}: <a href=\"http://coord.info/{1}\" target=\"_blank\">{1}</a>", Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHE), til[i].GeocacheCode);

                            string iconColor;
                            if (i == 0)
                            {
                                iconColor = "yellowIcon";
                            }
                            else if (i == til.Count - 1)
                            {
                                iconColor = "redIcon";
                            }
                            else
                            {
                                iconColor = "blueIcon";
                            }
                            sb.AppendFormat("createMarker('{5}-{0}', new google.maps.LatLng({1}, {2}), {3}, '{4}');", til[i].GeocacheCode, til[i].Lat.ToString().Replace(',', '.'), til[i].Lon.ToString().Replace(',', '.'), iconColor, bln.ToString().Replace("'", ""), i+1);
                        }

                        if (til.Count > 1)
                        {
                            sb.AppendLine();
                            sb.Append("var polylineA = new google.maps.Polyline({map: map, path: [");
                            for (int i = 0; i < til.Count; i++)
                            {
                                if (i > 0)
                                {
                                    sb.Append(",");
                                }
                                sb.AppendFormat("new google.maps.LatLng({0}, {1})", til[i].Lat.ToString().Replace(',', '.'), til[i].Lon.ToString().Replace(',', '.'));
                            }
                            sb.Append("], strokeColor: '#8A2BE2', strokeWeight: 4, strokeOpacity: .9});");
                        }
                        string html = htmlcontent.Replace("//patchwork", sb.ToString());
                        string fn = System.IO.Path.Combine(Core.PluginDataPath, "trackablesmap.html" );
                        File.WriteAllText(fn, html);
                        System.Diagnostics.Process.Start(fn);
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 19
0
 public Brake(TrackableItem bicycle) : base(bicycle)
 {
 }
Esempio n. 20
0
 public TrackedItem(User sbaseUser, TrackableItem what, int itmcount)
 {
     What     = what;
     count    = itmcount;
     baseUser = sbaseUser;
 }
        public ActionResult Edit(ObjectId id, TrackableItem ti)
        {
            try
            {

                if (ModelState.IsValid)
                {
                    var oldItem = _trackableItemsCollection.AsQueryable().FirstOrDefault(x => x.Id == id);
                    ti.States = oldItem.States;
                    _trackableItemsCollection.Save(ti);
                    return RedirectToAction("Index");
                }
                return View();
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Delete(ObjectId id, TrackableItem ti)
        {
            try
            {

                var item = _trackableItemsCollection.Remove(Query<TrackableItem>.EQ(x => x.Id, id));
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public TrackableItemDecorator(TrackableItem bicycle)
 {
     _bicycle = bicycle;
 }