public async Task <ActionResult> CreateNewFact(CreateNewFactRecordViewModel model) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var context = HttpContext.GetOwinContext().Get <ApplicationDbContext>(); if (ModelState.IsValid) { if (model.Id == 0) { FactRecord factRecord = new FactRecord() { Date = model.Date, Number = model.Number, PlanRecord = GetPlanRecord(model.IdPlanRecord) }; context.FactRecords.Add(factRecord); context.SaveChanges(); return(RedirectToAction("Index", new { Message = ManageMessageId.AddNewFactRecord })); } var factRecordForUpdate = (from c in context.FactRecords where c.Id == model.Id select c).FirstOrDefault(); factRecordForUpdate.Date = model.Date; factRecordForUpdate.Number = model.Number; context.SaveChanges(); return(RedirectToAction("Index", new { Message = ManageMessageId.UpdateFactRecord })); } // Это сообщение означает наличие ошибки; повторное отображение формы return(View(model)); }
public FactMemento Load(string domain, FactID factId) { lock (this) { FactRecord factRecord = _factTable.FirstOrDefault(o => o.IdentifiedFactMemento.Id.Equals(factId)); if (factRecord != null) { return(factRecord.IdentifiedFactMemento.Memento); } else { throw new CorrespondenceException( string.Format("Fact with id {0} not found.", factId)); } } }
public FactID?FindExistingFact(string domain, FactMemento memento) { lock (this) { // See if the fact already exists. FactRecord fact = _factTable.FirstOrDefault(o => o.IdentifiedFactMemento.Memento.Equals(memento)); if (fact == null) { return(null); } else { return(fact.IdentifiedFactMemento.Id); } } }
/// <summary> /// Updates the view. /// /// Will take the raw string data of the connections and create links to the notes. /// /// *Note: Once BackgroundTask is setup, this will be what is called from PROGRESS ... the core number crunching will take place in the handler sans interface /// </summary> void UpdateView() { if (tip == null) { tip = new ToolTip(); tip.ShowAlways = true; //BottomInfo.Controls.Add (tip); } // clear list for (int i = BottomInfo.Controls.Count - 1; i >= 0; i--) { if (BottomInfo.Controls[i].Name != REFRESH_BUTTON) { BottomInfo.Controls.Remove(BottomInfo.Controls[i]); } } if (results_to_store != null) { int count = 0; foreach (string s in results_to_store) { count++; // just for naming labels FactRecord factRecord = FactRecord.CreateFactRecord(s, true); if (factRecord != null) { GroupBox box = null; box = getGroupBoxForLayout(factRecord.layoutguid); if (box == null) { box = new GroupBox(); box.Dock = DockStyle.Left; box.Text = MasterOfLayouts.GetNameFromGuid(factRecord.layoutguid); box.Name = factRecord.layoutguid; box.AutoSize = true; box.MinimumSize = new Size(200, 75); box.AutoSizeMode = AutoSizeMode.GrowOnly; tip.SetToolTip(box, box.Text); } LinkLabel newLabel = new LinkLabel(); newLabel.Name = "label" + count; newLabel.Text = factRecord.chapter; newLabel.AutoSize = true; // if false, it will supply a tooltip and override mine newLabel.AutoEllipsis = false; string toolTip = factRecord.text.Substring(0, Math.Min(100, factRecord.text.Length)); // also used for the search newLabel.Dock = DockStyle.Left; newLabel.Click += (object sender, EventArgs e) => { LayoutDetails.Instance.LoadLayout(factRecord.layoutguid, factRecord.noteguid, toolTip /*"[["+factRecord.theFact*/); // NewMessage.Show (factRecord.layoutguid + " -- " + factRecord.noteguid); }; box.Controls.Add(newLabel); BottomInfo.Controls.Add(box); //tip.SetToolTip(box, "Hello there boxy"); // NewMessage.Show (factRecord.text); tip.SetToolTip(newLabel, toolTip); //tip.SetToolTip(newLabel, "zippy"); worked //NewMessage.Show (factRecord.ToString ()); } else { NewMessage.Show("Fact Record was null for : " + s); } } //ok: this works. Now the hard part // NewMessage.Show ("Matches are = " + results_to_store.Count); } }
public FactID Save(string domain, FactMemento fact, Guid clientGuid) { FactID factId; List <FactID> affectedPivots; lock (this) { // See if the fact already exists. FactRecord existingFact = _factTable.FirstOrDefault(o => o.IdentifiedFactMemento.Memento.Equals(fact)); if (existingFact == null) { // It doesn't, so create it. FactID newFactID = new FactID() { key = _factTable.Count + 1 }; factId = newFactID; existingFact = new FactRecord() { IdentifiedFactMemento = new IdentifiedFactMemento(factId, fact) }; _factTable.Add(existingFact); // Store a message for each pivot. var pivots = fact.Predecessors .Where(predecessor => predecessor.IsPivot); _messageTable.AddRange(pivots .Select(predecessor => new MessageRecord( new MessageMemento(predecessor.ID, newFactID), newFactID, predecessor.Role, clientGuid))); // Store messages for each non-pivot. This fact belongs to all predecessors' pivots. List <FactID> nonPivots = fact.Predecessors .Where(predecessor => !predecessor.IsPivot) .Select(predecessor => predecessor.ID) .ToList(); List <MessageRecord> predecessorsPivots = _messageTable .Where(message => nonPivots.Contains(message.Message.FactId)) .Distinct() .ToList(); _messageTable.AddRange(predecessorsPivots .Select(predecessorPivot => new MessageRecord( new MessageMemento(predecessorPivot.Message.PivotId, newFactID), predecessorPivot.AncestorFact, predecessorPivot.AncestorRole, clientGuid))); affectedPivots = pivots .Select(pivot => pivot.ID) .Union(predecessorsPivots .Select(predecessorPivot => predecessorPivot.Message.PivotId)) .ToList(); } else { factId = existingFact.IdentifiedFactMemento.Id; affectedPivots = null; } } if (affectedPivots != null && affectedPivots.Any() && PivotAffected != null) { foreach (var pivotId in affectedPivots) { PivotAffected(domain, pivotId, factId, clientGuid); } } return(factId); }