Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            ScalableVectorGraphic scalableVectorGraphic = await db.ScalableVectorGraphics.FindAsync(id);

            db.ScalableVectorGraphics.Remove(scalableVectorGraphic);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #4
0
        public IHttpActionResult GetScalableVectorGraphic(Guid id)
        {
            ScalableVectorGraphic scalableVectorGraphic = db.ScalableVectorGraphics.Find(id);

            if (scalableVectorGraphic == null)
            {
                return(NotFound());
            }

            return(Ok(scalableVectorGraphic));
        }
Example #5
0
        // 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));
        }
Example #6
0
        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));
        }
Example #7
0
        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));
        }
Example #8
0
        // 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));
        }
Example #9
0
        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));
        }