Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes the RawSymbolImport with id as parameter id.
        /// Redirects to the Index-method in RawListController together with
        /// a message of error or success.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>~/RawList/Index.cshtml</returns>
        public ActionResult Delete(int id)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

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

            var name = toDelete.rawName;

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

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
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");
        }