/// <summary>
        /// Takes an id and deletes the corresponding CompositeSymbol.
        /// Returns you to the Index-method of the CompositeSymbolController
        /// together with a message of error or success.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Index-view</returns>
        public ActionResult Delete(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            CompositeSymbolBLL comp = new CompositeSymbolBLL();
            CompositeSymbol toDelete = comp.GetExaxtComositeSymbolByID(id);

            var name = toDelete.compName;

            if (toDelete != null)
            {
                var ok = comp.DeleteCompositeSymbol(toDelete);
                if (ok)
                {
                    TempData["msg"] = "Composite Symbol '" + name + "' was successfully deleted.";
                }
                else
                {
                    TempData["msg"] = "Could not delete symbol '" + name + "'.";
                }
            }
            else
            {
                TempData["msg"] = "Composite Symbol with id: '" + id + "' was not found.";
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stores all Symbols in ViewData["symbols"],
        /// all symbols with symboltype other than normal in ViewDate["types"],
        /// and all CompositeSymbols in ViewData["comp"], 
        /// and returns the index-view of WriteController.
        /// </summary>
        /// <returns>~/Write/Inex.cshtml</returns>
        public ActionResult Index()
        {
            SymbolBLL symbols = new SymbolBLL();
            ViewData["symbols"] = symbols.GetAllSymbols();

            SymbolTypeBLL types = new SymbolTypeBLL();
            ViewData["types"] = types.GetAllNonStandard();

            CompositeSymbolBLL comp = new CompositeSymbolBLL();
            ViewData["comp"] = comp.GetAll();

            CompositeOfBLL compOf = new CompositeOfBLL();
            ViewData["compOf"] = compOf.getAllRelations();

            return View();
        }
        /// <summary>
        /// Gets the id of the CompositeSymbol you want to edit, 
        /// the symbols it is made of, and a list of all Symbols,
        /// saves them in ViewData and then returns the Edit-view.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Edit-view</returns>
        public ActionResult Edit(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            CompositeSymbolBLL comp = new CompositeSymbolBLL();
            CompositeSymbol find = comp.GetExaxtComositeSymbolByID(id);

            CompositeOfBLL compOf = new CompositeOfBLL();

            SymbolBLL symb = new SymbolBLL();

            List<Symbol> symbols = compOf.GetComponentsOf(find);

            SymbolTypeBLL types = new SymbolTypeBLL();

            ViewData["comp"] = find;
            ViewData["symbList"] = symbols;
            ViewData["otherSymbols"] = symb.GetAllSymbols();
            ViewData["Types"] = types.GetAllNonStandard();
            return View();
        }
Ejemplo n.º 4
0
        public ActionResult ConvertToComposite(Int32[] isPartOf, int rawId)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            RawSymbolImportBLL raw = new RawSymbolImportBLL();
            SymbolBLL symbols = new SymbolBLL();
            CompositeSymbolBLL comp = new CompositeSymbolBLL();

            RawSymbolImport rawBecomingComp = raw.GetExact(rawId);
            List<Symbol> partOf = new List<Symbol>();

            foreach (Int32 part in isPartOf)
            {
                var temp = symbols.GetExactByID(part);
                if (temp != null)
                {
                    partOf.Add(temp);
                }
            }

            CompositeSymbol compOfRaw = new CompositeSymbol()
            {
                compId = rawBecomingComp.rawId,
                compName = rawBecomingComp.rawName,
                compJpeg = rawBecomingComp.rawJpeg
            };

            var ok = comp.Insert(compOfRaw, partOf);
            if (ok != -1)
            {
                TempData["msg"] = "Raw symbol '" + rawBecomingComp.rawName + "' is now a composite symbol";
                var successfullyDeleted = raw.DeleteExact(rawId);
                if(!successfullyDeleted)
                {
                    TempData["msg"] += ", but was not deleted from raw list.";
                }
            }
            return RedirectToAction("Index", "CompositeSymbol");
        }
Ejemplo n.º 5
0
        public ActionResult Suggestions(SuggestionsModel myModel)
        {
            var symbolId = myModel.symbolId;
            var currentSuggestions = myModel.currentSuggestions;
            var first = myModel.first;

            System.Diagnostics.Debug.WriteLine(first + " AND ID IS " + symbolId + " SIR");
            var listOfComp = new List<CompositeSymbol>();
            if(first == "true")
            {
                CompositeSymbolBLL comp = new CompositeSymbolBLL();
                listOfComp = comp.GetAll();
                System.Diagnostics.Debug.WriteLine("FILLED LIST WITH ALL COMP SYMBOLS FROM BLL SIR");
            }
            else
            {
                foreach(CompositeSymbol co in currentSuggestions)
                {
                    CompositeSymbolBLL comp = new CompositeSymbolBLL();
                    listOfComp.Add(comp.GetExaxtComositeSymbolByID(co.compId));
                }
                //listOfComp = currentSuggestions;
                System.Diagnostics.Debug.WriteLine("NUMBER IS: " + currentSuggestions.Count + ", FILLING LIST WITH LIST IN PARAMETER SIR");
            }

            if(listOfComp.Count == 0)
            {
                System.Diagnostics.Debug.WriteLine("VERY EMPTY THIS LIST SIR");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("LIST HAS VALUES SIR");
            }

            CompositeOfBLL compOf = new CompositeOfBLL();
            CompositeScoreBLL score = new CompositeScoreBLL();
            List<CompositeSymbol> suggestions = new List<CompositeSymbol>();

            var lastScore = 0;
            foreach(CompositeSymbol c in listOfComp)
            {
                if (c != null)
                    System.Diagnostics.Debug.WriteLine("COMP SYMBOL DOES EXCIST SIR");
                else
                    System.Diagnostics.Debug.WriteLine("COMP SYMBOL DOES NOT EXIST SIR");

                var temp = compOf.GetComponentsOf(c);
                foreach(Symbol s in temp)
                {
                    if(s.symId == symbolId)
                    {
                        if(score.GetScoreFor(c.compId) >= lastScore)
                        {
                            suggestions.Insert(0, c);
                            lastScore = score.GetScoreFor(c.compId);
                        }
                        else
                            suggestions.Add(c);
                    }
                }
            }

            return Json(suggestions);
        }
        public ActionResult Edit(Int32[] isPartOf, int compId)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            CompositeSymbolBLL comp = new CompositeSymbolBLL();
            SymbolBLL symbols = new SymbolBLL();

            CompositeSymbol editedComp = comp.GetExaxtComositeSymbolByID(compId);
            List<Symbol> partOf = new List<Symbol>();

            foreach(Int32 part in isPartOf)
            {
                var temp = symbols.GetExactByID(part);
                if(temp != null)
                {
                    partOf.Add(temp);
                }
            }

            CompositeOfBLL compOf = new CompositeOfBLL();
            var ok = compOf.DeleteByCompositeSymbol(editedComp);
            if(ok)
            {
                ok = compOf.SetCompositeOfSymbol(editedComp, partOf);
                if(ok)
                {
                    TempData["msg"] = "Composite Symbol '" + editedComp.compName + "' was successfully edited.";
                }
                else
                {
                    TempData["msg"] = "Error when editing.";
                }
            }
            return RedirectToAction("Index");
        }
 /// <summary>
 /// Generates a list of all the CompositeSymbols and 
 /// saves it in ViewData, and then returns the Index-view.
 /// It also sends an error message to the view if it exists.
 /// </summary>
 /// <param></param>
 /// <returns>Index-view</returns>
 public ActionResult Index()
 {
     CompositeSymbolBLL comp = new CompositeSymbolBLL();
     ViewData["comp"] = comp.GetAll();
     if (TempData["msg"] != null)
     {
         ViewBag.Message = TempData["msg"].ToString();
     }
     return View();
 }