Exemplo n.º 1
0
        public async Task<IHttpActionResult> PutAppartmentType(int id, AppartmentType appartmentType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        public async Task<IHttpActionResult> PostAppartmentType(AppartmentType appartmentType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.AppartmentTypes.Add(appartmentType);
            await db.SaveChangesAsync();

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