/// <summary> /// Takes an int id as parameter and finds the corresponding /// RawSymbolImport. Saves it in ViewData["raw"] and returns /// the AddAsBaseSymbol-view. /// </summary> /// <param name="id"></param> /// <returns>~/RawList/AddAsBaseSymbol.cshtml</returns> public ActionResult AddAsBaseSymbol(int id) { if (Session["logged_in"] == null) return RedirectToAction("Index", "Index"); RawSymbolImportBLL rawImport = new RawSymbolImportBLL(); RawSymbolImport toConvert = rawImport.GetExact(id); ViewData["raw"] = toConvert; return View(); }
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"); }
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> /// 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"); }
/// <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(); }