예제 #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));
        }
예제 #2
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));
        }