예제 #1
0
        /// <summary>
        /// Deletes the Symbol with the same id as parameter id.
        /// Redirects to the index-method of SymbolController,
        /// together with a message of error or success.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>~/Symbol/Index.cshtml</returns>
        public ActionResult Delete(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            SymbolBLL symb = new SymbolBLL();
            Symbol toDelete = symb.GetExactByID(id);

            var name = toDelete.symName;

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

            return RedirectToAction("Index");
        }
        public ActionResult AddAsBaseSymbol(int rawId, int symbolType)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            RawSymbolImportBLL rawImport = new RawSymbolImportBLL();
            RawSymbolImport toConvert = rawImport.GetExact(rawId);

            SymbolBLL symbols = new SymbolBLL();
            var returnedId = symbols.Insert(toConvert.rawName, toConvert.rawJpeg);
            if (returnedId != -1)
            {
                TempData["msg"] = "Success";

                RawSymbolImportBLL raws = new RawSymbolImportBLL();
                var ok = raws.DeleteExact(rawId);
                if (!ok)
                {
                    TempData["msg"] += ", but could not delete symbol from raw list.";
                }

                if(symbolType != 0)
                {
                    SymbolTypeBLL symbolTypes = new SymbolTypeBLL();
                    TypeCodes type;

                    if (symbolType == 1)
                    {
                        type = TypeCodes.INDICATOR;
                    }
                    else if (symbolType == 2)
                    {
                        type = TypeCodes.NUMERICAL;
                    }
                    else
                    {
                        type = TypeCodes.LATIN;
                    }

                    symbolTypes.SetLanguageForSymID(returnedId, type);
                }
            }
            else
            {
                TempData["msg"] = "Could not add symbol as base.";
            }

            return RedirectToAction("Index", "Symbol");
        }
예제 #3
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();
        }
예제 #4
0
        /// <summary>
        /// Finds the Symbol with the same id as the parameter id,
        /// and stores it in ViewData["symb"].
        /// Returns the Edit-view.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>~/Symbol/Edit.cshtml</returns>
        public ActionResult Edit(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            if(id != 0)
            {
                SymbolBLL symbols = new SymbolBLL();
                Symbol toEdit = symbols.GetExactByID(id);

                if(toEdit == null)
                {
                    TempData["msg"] = "Could not find symbol with id " + id;
                }
                else
                {
                    SymbolTypeBLL types = new SymbolTypeBLL();
                    try
                    {
                        ViewData["symbol"] = toEdit;
                        TypeCodes type = types.GetExactBySymID(id).typeIndicator;
                        ViewData["type"] = type;
                        return View();
                    }
                    catch(NullReferenceException)
                    {
                        ViewData["type"] = null;
                        return View();
                    }

                }
            }
            else
            {
                TempData["msg"] = "Invalid Id.";
            }

            return RedirectToAction("Index");
        }
        /// <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();
        }
예제 #6
0
 /// <summary>
 /// Returns the index-view together with a list of all symbols
 /// stored in ViewData["symb"], and a message if it exists.
 /// </summary>
 /// <returns>~/Symbol/Index.cshtml</returns>
 public ActionResult Index()
 {
     SymbolBLL symb = new SymbolBLL();
     SymbolTypeBLL types = new SymbolTypeBLL();
     ViewData["types"] = types.GetAllNonStandard();
     ViewData["symb"] = symb.GetAllSymbols();
     if (TempData["msg"] != null)
     {
         ViewBag.Message = TempData["msg"].ToString();
     }
     return View();
 }
예제 #7
0
        public ActionResult Edit(int symbolId, int symbolType)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            if(symbolId != 0)
            {
                SymbolBLL symbols = new SymbolBLL();
                Symbol toEdit = symbols.GetExactByID(symbolId);

                if(toEdit != null)
                {
                    if(symbolType == 0)
                    {
                        SymbolTypeBLL types = new SymbolTypeBLL();
                        types.SetStandardForSymID(toEdit.symId);
                    }
                    else
                    {
                        TypeCodes type = new TypeCodes();

                        switch (symbolType)
                        {
                            case 1: type = TypeCodes.INDICATOR;
                                break;
                            case 2: type = TypeCodes.NUMERICAL;
                                break;
                            case 3: type = TypeCodes.LATIN;
                                break;
                        }

                        SymbolTypeBLL types = new SymbolTypeBLL();
                        if(types.GetExactBySymID(toEdit.symId) != null)
                        {
                            types.UpdateTypeForSymID(toEdit.symId, type);
                        }
                        else
                        {
                            types.SetLanguageForSymID(toEdit.symId, type);
                        }
                    }
                    TempData["msg"] = "Symbol with id " + symbolId + " was successfully edited!";
                }
                else
                {
                    TempData["msg"] = "Could find and edit symbol with id " + symbolId;
                }
            }
            else
            {
                TempData["msg"] = "SymbolId is not valid.";
            }
            return RedirectToAction("Index");
        }
        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");
        }
        /// <summary>
        /// Takes int id as parameter and finds the corresponding RawSymbolImport.
        /// Saves the RawSymbolImport and a list of all Symbols in Viewdata["raw"] and
        /// Viewdata["symbList"] respectively, and returns the ConvertToComposite-view.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>~/RawList/ConvertToComposite.cshtml</returns>
        public ActionResult ConvertToComposite(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            RawSymbolImportBLL raw = new RawSymbolImportBLL();
            RawSymbolImport find = raw.GetExact(id);

            SymbolBLL symb = new SymbolBLL();

            SymbolTypeBLL types = new SymbolTypeBLL();

            ViewData["raw"] = find;
            ViewData["symbList"] = symb.GetAllSymbols();
            ViewData["types"] = types.GetAllNonStandard();
            return View();
        }
        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");
        }