Esempio n. 1
0
        public async Task <IHttpActionResult> PutLocal(int id, LocalPOCO localParametro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != localParametro.Id)
            {
                return(BadRequest());
            }

            db.Entry(localParametro.toDb()).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> PostLocal(LocalPOCO localParametro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var loc = db.Local.Add(localParametro.toDb());
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = loc.Id }, new LocalPOCO(loc)));
        }