public async Task <IHttpActionResult> PutPerson(int id, Person person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public async Task AddAsync(Apartment entity)
 {
     _context.Set <Apartment>().Add(entity);
     await _context.SaveChangesAsync();
 }
Example #3
0
 public async Task AddAsync(Location entity)
 {
     _context.Set <Location>().Add(entity);
     await _context.SaveChangesAsync();
 }