Esempio n. 1
0
        public async Task<IHttpActionResult> PostFormasPago(FormasPago formasPago)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.FormasPago.Add(formasPago);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (FormasPagoExists(formasPago.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = formasPago.Id }, formasPago);
        }
Esempio n. 2
0
        public async Task<IHttpActionResult> PutFormasPago(string id, FormasPago formasPago)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

            db.Entry(formasPago).State = EntityState.Modified;

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

            return StatusCode(HttpStatusCode.NoContent);
        }