Пример #1
0
        public async Task<IHttpActionResult> PutIdentity(int id, Identity identity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
        public async Task<IHttpActionResult> PostIdentity(Identity identity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Identity.Add(identity);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = identity.Id }, identity);
        }
Пример #3
0
        // POST: odata/Identities
        public async Task<IHttpActionResult> Post(Identity identity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Identity.Add(identity);
            await db.SaveChangesAsync();

            return Created(identity);
        }