public virtual ActionResult DeleteConfirmed(int id) { SymbolDrawing symbolDrawing = db.SymbolDrawings.Find(id); db.SymbolDrawings.Remove(symbolDrawing); db.SaveChanges(); return(RedirectToAction("Index")); }
public virtual ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SymbolDrawing symbolDrawing = db.SymbolDrawings.Find(id); if (symbolDrawing == null) { return(HttpNotFound()); } return(View(symbolDrawing)); }
private SymbolDrawing insertSymbolDrawingFromJson(string jsonData, Symbol symbol, bool drawnUsingTouch) { RawDrawing drawing; try { var lines = JsonConvert.DeserializeObject <RawPoint[][]>(jsonData); drawing = new RawDrawing() { Lines = lines }; } catch (Exception ex) { return(null); } new RawDataProcessor().CleanData(drawing); if (drawing.LinesCount == 0) { return(null); } var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); ApplicationUser author = User.Identity.IsAuthenticated ? userManager.FindById(User.Identity.GetUserId()) : null; var sd = new SymbolDrawing() { Symbol = symbol, CreatedDateTime = DateTime.UtcNow, DrawnUsingTouch = drawnUsingTouch, Creator = author, Approved = (author == null || userManager.IsInRole(author.Id, RolesHelper.Teacher) == false) ? null : (bool?)true }; sd.SetRawDrawing(drawing); sd = db.SymbolDrawings.Add(sd); db.SaveChanges(); Logger.LogInfo <TeachController>("New symbol drawing [{0}].", sd.SymbolDrawingId); return(sd); }