Пример #1
0
        public IHttpActionResult PostAspNetUserRole(AspNetUserRole aspnetuserrole)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.AspNetUserRoles.Add(aspnetuserrole);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (AspNetUserRoleExists(aspnetuserrole.UserId))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = aspnetuserrole.UserId }, aspnetuserrole);
        }
Пример #2
0
        // PUT api/KullaniciRolu/5
        public IHttpActionResult PutAspNetUserRole(string id, AspNetUserRole aspnetuserrole)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != aspnetuserrole.UserId)
            {
                return BadRequest();
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AspNetUserRoleExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }