public ActionResult ModuleAddFile(string Link, string Text, int Id) { if (ModelState.IsValid) { ViewBag.Email = _userManager.GetUserName(HttpContext.User); ModuleReferenceList referenceList = new ModuleReferenceList(); referenceList.Link = Link; referenceList.Text = Text; referenceList.ModuleId = Id; _context.ModuleReferenceList.Add(referenceList); _context.SaveChanges(); return(RedirectToAction("ModuleView", new { Id = Id })); } return(View()); }
public virtual ModuleReferenceList VisitModuleReferenceList(ModuleReferenceList moduleReferences, ModuleReferenceList changes, ModuleReferenceList deletions, ModuleReferenceList insertions){ return moduleReferences; }
public virtual Differences VisitModuleReferenceList(ModuleReferenceList list1, ModuleReferenceList list2, out ModuleReferenceList changes, out ModuleReferenceList deletions, out ModuleReferenceList insertions){ changes = list1 == null ? null : list1.Clone(); deletions = list1 == null ? null : list1.Clone(); insertions = list1 == null ? new ModuleReferenceList() : list1.Clone(); //^ assert insertions != null; Differences differences = new Differences(); //Compare definitions that have matching key attributes TrivialHashtable matchingPosFor = new TrivialHashtable(); TrivialHashtable matchedNodes = new TrivialHashtable(); for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){ //^ assert list2 != null; ModuleReference nd2 = list2[j]; if (nd2 == null || nd2.Name == null) continue; matchingPosFor[Identifier.For(nd2.Name).UniqueIdKey] = j; insertions.Add(null); } for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){ //^ assert list1 != null && changes != null && deletions != null; ModuleReference nd1 = list1[i]; if (nd1 == null || nd1.Name == null) continue; object pos = matchingPosFor[Identifier.For(nd1.Name).UniqueIdKey]; if (!(pos is int)) continue; //^ assert pos != null; //^ assume list2 != null; //since there was entry int matchingPosFor int j = (int)pos; ModuleReference nd2 = list2[j]; //^ assume nd2 != null; //nd1 and nd2 have the same key attributes and are therefore treated as the same entity matchedNodes[nd1.UniqueKey] = nd1; matchedNodes[nd2.UniqueKey] = nd2; //nd1 and nd2 may still be different, though, so find out how different Differences diff = this.VisitModuleReference(nd1, nd2); if (diff == null){Debug.Assert(false); continue;} if (diff.NumberOfDifferences != 0){ changes[i] = diff.Changes as ModuleReference; deletions[i] = diff.Deletions as ModuleReference; insertions[i] = diff.Insertions as ModuleReference; insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; continue; } changes[i] = null; deletions[i] = null; insertions[i] = null; insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation } //Find deletions for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){ //^ assert list1 != null && changes != null && deletions != null; ModuleReference nd1 = list1[i]; if (nd1 == null) continue; if (matchedNodes[nd1.UniqueKey] != null) continue; changes[i] = null; deletions[i] = nd1; insertions[i] = null; differences.NumberOfDifferences += 1; } //Find insertions for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){ //^ assert list2 != null; ModuleReference nd2 = list2[j]; if (nd2 == null) continue; if (matchedNodes[nd2.UniqueKey] != null) continue; insertions[n+j] = nd2; //Records nd2 as an insertion into list1, along with its position in list2 differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here? } if (differences.NumberOfDifferences == 0){ changes = null; deletions = null; insertions = null; } return differences; }