/// <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 SymbolAdministration(HttpPostedFileBase[] files) { /* Refrences used * http://www.aspdotnet-pools.com/2014/06/multiple-file-upload-with-aspnet-mvc-c.html */ List<string> extensions = new List<string> { ".jpg", ".jpeg", ".png" }; int maxFileSize = 51200; try { int i = 0; foreach (HttpPostedFileBase file in files) { // Save files to Import directory string filename = System.IO.Path.GetFileName(file.FileName).ToLower(); // Check extention if (extensions.Contains(Path.GetExtension(filename)) && file.ContentLength < maxFileSize) { file.SaveAs(Server.MapPath("~/Import/" + filename)); i++; } } ViewBag.Message = "There were: " + i + " file(s) uploaded successfully"; } catch(Exception e) { ViewBag.Message = "Error trying to upload files."; Console.WriteLine(e.StackTrace); } // Import files to db RawSymbolImportBLL rawImport = new RawSymbolImportBLL(); rawImport.ImportFromPath("Import"); return View(); }
/// <summary> /// Returns the Index-view together with the list of /// all the RawImportSymbols in the DB. Sends a message aswell, if it exists /// </summary> /// <returns>~/RawList/Index.cshtml</returns> public ActionResult Index() { RawSymbolImportBLL raw = new RawSymbolImportBLL(); ViewData["raw"] = raw.GetAll(); if(TempData["msg"] != null) { ViewBag.Message = TempData["msg"].ToString(); } return View(); }
public ActionResult DeleteAll() { if (Session["logged_in"] == null) return RedirectToAction("Index", "Index"); RawSymbolImportBLL rawImport = new RawSymbolImportBLL(); TempData["msg"] = (rawImport.DeleteAll()) ? "All raw symbols deleted" : "Error trying to delete files."; return RedirectToAction("Index"); }
/// <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"); }
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(); }