public IHttpActionResult PostScalableVectorGraphic(ScalableVectorGraphic scalableVectorGraphic) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ISvgService sgvService = new SgvNetService(); if (sgvService.ValidateInlineSgv(scalableVectorGraphic.SgvSpecs)) { db.ScalableVectorGraphics.Add(scalableVectorGraphic); } try { db.SaveChanges(); } catch (DbUpdateException) { if (ScalableVectorGraphicExists(scalableVectorGraphic.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = scalableVectorGraphic.Id }, scalableVectorGraphic)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Title,SgvSpecs")] ScalableVectorGraphic scalableVectorGraphic, HttpPostedFileBase image) { if (image != null) { scalableVectorGraphic.SgvSpecs = _svgService.getXmlfromFile(image); } if (_svgService.ValidateInlineSgv(scalableVectorGraphic.SgvSpecs)) { scalableVectorGraphic.DateCreated = DateTime.UtcNow; if (ModelState.IsValid) { scalableVectorGraphic.Id = Guid.NewGuid(); db.ScalableVectorGraphics.Add(scalableVectorGraphic); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } else { ModelState.AddModelError("", "The information for the sgv specification could be wrong, please check your file"); } return(View(scalableVectorGraphic)); }
public async Task <ActionResult> DeleteConfirmed(Guid id) { ScalableVectorGraphic scalableVectorGraphic = await db.ScalableVectorGraphics.FindAsync(id); db.ScalableVectorGraphics.Remove(scalableVectorGraphic); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public IHttpActionResult GetScalableVectorGraphic(Guid id) { ScalableVectorGraphic scalableVectorGraphic = db.ScalableVectorGraphics.Find(id); if (scalableVectorGraphic == null) { return(NotFound()); } return(Ok(scalableVectorGraphic)); }
// GET: ScalableVectorGraphics/Delete/5 public async Task <ActionResult> Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ScalableVectorGraphic scalableVectorGraphic = await db.ScalableVectorGraphics.FindAsync(id); if (scalableVectorGraphic == null) { return(HttpNotFound()); } return(View(scalableVectorGraphic)); }
public IHttpActionResult DeleteScalableVectorGraphic(Guid id) { ScalableVectorGraphic scalableVectorGraphic = db.ScalableVectorGraphics.Find(id); if (scalableVectorGraphic == null) { return(NotFound()); } db.ScalableVectorGraphics.Remove(scalableVectorGraphic); db.SaveChanges(); return(Ok(scalableVectorGraphic)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Title,SgvSpecs,DateCreated")] ScalableVectorGraphic scalableVectorGraphic, HttpPostedFileBase image) { if (image != null) { scalableVectorGraphic.SgvSpecs = _svgService.getXmlfromFile(image); } if (ModelState.IsValid) { db.Entry(scalableVectorGraphic).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(scalableVectorGraphic)); }
// GET: ScalableVectorGraphics/Details/5 public async Task <ActionResult> Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ScalableVectorGraphic scalableVectorGraphic = await db.ScalableVectorGraphics.FindAsync(id); if (scalableVectorGraphic == null) { return(HttpNotFound()); } var sgvWithResized = new SgvWithResizedInline(); sgvWithResized.sgv = scalableVectorGraphic; sgvWithResized.SgvResized = _svgService.SgvResize(scalableVectorGraphic.SgvSpecs, 300, 300); return(View(sgvWithResized)); }
public IHttpActionResult PutScalableVectorGraphic(Guid id, ScalableVectorGraphic scalableVectorGraphic) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != scalableVectorGraphic.Id) { return(BadRequest()); } ISvgService sgvService = new SgvNetService(); if (sgvService.ValidateInlineSgv(scalableVectorGraphic.SgvSpecs)) { db.Entry(scalableVectorGraphic).State = EntityState.Modified; } try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ScalableVectorGraphicExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }