public void saveChanges()
        {
            using (var db = new PlanningContext())
            {
                device_url data = null;

                if (!this._isCreateMode)
                {
                    var id = Convert.ToInt32(this.device_url_id.Text);
                    data = db.device_url.Where(d => d.device_url_id == id).FirstOrDefault();
                    if (data == null)
                    {
                        this._mainInterface.statusText = $"ERROR: ID '{this.device_url_id.Text}' does not exist.";
                        return;
                    }
                }
                else
                {
                    data = new device_url();
                }

                data.device_url_id = Convert.ToInt32(this.device_url_id.Text);
                data.url           = /**/ (this.url.Text);
                data.is_active     = (bool)this.is_active.IsChecked;
                data.comment       = /**/ (this.comment.Text);
                data.device        = new Func <device>(() => { foreach (var v in db.devices)
                                                               {
                                                                   if (v.device_id == (this.device.item as device).device_id)
                                                                   {
                                                                       return(v);
                                                                   }
                                                               }
                                                               return(null); })();


                if (this._isCreateMode)
                {
                    db.device_url.Add(data);
                }
                db.SaveChanges();
            }
        }
        public void deleteItem(object item)
        {
            if (item == null)
            {
                return;
            }

            device_url data = item as device_url;

            if (data == null)
            {
                return;
            }

            using (var db = new PlanningContext())
            {
                db.device_url.Remove(db.device_url.Where(d => d.device_url_id == data.device_url_id).First());
                db.SaveChanges();
            }
        }