public ActionResult Edit(Guid id)
 {
     var m = new SavedQueryInfo(id);
     if (m.Name.Equals(Util.ScratchPad2))
         m.Name = "copy of scratchpad";
     return View(m);
 }
 public ActionResult Update(SavedQueryInfo m)
 {
     if (m.Name.Equal(Util.ScratchPad2))
         m.Ispublic = false;
     m.CanDelete = true; // must be true since they can edit if they got here
     m.UpdateModel();
     return View("Row", m);
 }
Exemple #3
0
 public ActionResult SaveAs(Guid id, string nametosaveas)
 {
     if (nametosaveas.Equals(Util.ScratchPad2))
         nametosaveas = "copy of scratchpad";
     var m2 = new SavedQueryInfo(id) { Name = nametosaveas };
     return View(m2);
 }
Exemple #4
0
        public ActionResult Save(string name, string value, SavedQueryInfo m)
        {
            var query = DbUtil.Db.LoadQueryById2(m.QueryId);
            var previous = (from p in DbUtil.Db.Queries
                            where p.Owner == m.Owner
                            where p.Name == name
                            orderby p.LastRun
                            select p).FirstOrDefault();
            if (previous != null)
            {
                // copying over a previous query with same name and owner
                m.CopyPropertiesTo(previous);
                previous.Text = query.Text;
                if (previous.Name.Equal(Util.ScratchPad2))
                    previous.Ispublic = false;
                DbUtil.Db.SubmitChanges();
                return Redirect("/Query/" + previous.QueryId);

                //                m.CopyPropertiesTo(previous);
                //                var pc = previous.ToClause();
                //                pc.Reset(DbUtil.Db);
                //                pc = Condition.Import(query.Text, name, newGuids: true, topguid: previous.QueryId);
                //                previous.Text = pc.ToXml();
                //                DbUtil.Db.SubmitChanges();
                //                return Redirect("/Query/" + previous.QueryId);
            }
            // saving to a new query
            m.CopyPropertiesTo(query);
            if (query.Name.Equal(Util.ScratchPad2))
                query.Ispublic = false;
            DbUtil.Db.SubmitChanges();
            return Redirect("/Query/" + m.QueryId);
        }