Example #1
0
        // POST: odata/Multas
        public IHttpActionResult Post(MultasModel multasModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Multa.Add(multasModel);
            db.SaveChanges();

            return(Created(multasModel));
        }
Example #2
0
        // DELETE: odata/Multas(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            MultasModel multasModel = db.Multa.Find(key);

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

            db.Multa.Remove(multasModel);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <MultasModel> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            MultasModel multasModel = db.Multa.Find(key);

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

            patch.Patch(multasModel);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MultasModelExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(multasModel));
        }