public ActionResult ViewData(string tableName) { var table = _currentDatabase.Tables.FirstOrDefault(x => x.Name == tableName); if (table != null) { var dataList = DBreezeOperations.GetAllData(_dBreeze, table.Name); if (dataList == null) { table.DataList = new Dictionary <string, string>(); } else { table.DataList = dataList; } _currentTable = table; } return(View(_currentTable)); }
public ActionResult CreateQuery(SimpleQuery query) { if (query.Type == QueryType.Insert) { DBreezeOperations.AddData(_dBreeze, query); //DBreezeOperations.GetDataPK(_dBreeze, _currentTable, _currentTable.PrimaryKey, FieldType.number, ConditionType.Less, "10"); //DBreezeOperations.GetConditionedData(_dBreeze, _currentTable, "firsstname", FieldType.varchar, ConditionType.Equal, "ell"); } else { var deleted = DBreezeOperations.DeleteData(_dBreeze, query, _currentTable, _currentDatabase); if (!deleted) { ModelState.AddModelError("", "Can't delete! Its a parent table!!!"); return(View("_DeleteData", query)); //return Json(new {status = "error", message = "Message error"}); } } _currentTable.DataList = DBreezeOperations.GetAllData(_dBreeze, _currentTable.Name); return(View("ViewData", _currentTable)); }
public ActionResult AddIndex(Table table) { var realField = new Field(); var realTable = new Table(); foreach (var db in _databases) { foreach (var t in db.Tables) { if (t.Name == table.Name) { foreach (var f in t.Fields) { if (f.Name == table.Index) { realField = f; realTable = t; } } } } } var indexFile = new IndexFile { Indexs = new List <Index>() { new Index { IndexName = table.FileName } }, // index name is set on FileName attribute in _AddIndex.cshtml KeyLength = realField.Length, FileName = $"{table.FileName}.ind", IndexType = table.IndexType, IsUnique = table.IndexUnique }; if (!_currentTable.IndexFiles.Any(c => c.Indexs.Any(z => z.IndexName == table.Index))) { if (table.IndexUnique) { _currentTable.IndexFiles.Add(indexFile); var value = string.Empty; var fieldsNotPk = realTable.Fields.Where(c => realTable.PrimaryKey != c.Name); foreach (var s in fieldsNotPk) { if (s.Name != indexFile.Indexs.FirstOrDefault()?.IndexName) { value += s.Name + "#"; } } value = value.Remove(value.Length - 1); using (var tranz = _dBreeze.GetTransaction()) { if (!_dBreeze.Scheme.IfUserTableExists(table.FileName)) { tranz.InsertTable(table.FileName, table.Index, 0); var pairs = DBreezeOperations.GetAllData(_dBreeze, table.Name).OrderBy(c => c.Key); foreach (var v in pairs) { tranz.Insert(table.Index, v.Key, v.Value); } } tranz.Commit(); } } } else { // non-unique index file } return(View("Fields", _currentTable)); }