コード例 #1
0
        public IHttpActionResult PutUserRole(int id, UserRole userRole)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != userRole.UserRoleID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostUserRole(UserRole userRole)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.UserRoles.Add(userRole);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = userRole.UserRoleID }, userRole);
        }
コード例 #3
0
ファイル: UserRoleAssembler.cs プロジェクト: Hardik21/JobsABA
        /// <summary>
        /// Converts this instance of <see cref="UserRoleDTO"/> to an instance of <see cref="UserRole"/>.
        /// </summary>
        /// <param name="dto"><see cref="UserRoleDTO"/> to convert.</param>
        public static UserRole ToEntity(this UserRoleDTO dto)
        {
            if (dto == null) return null;

            var entity = new UserRole();

            entity.UserRoleID = dto.UserRoleID;
            entity.UserID = dto.UserID;
            entity.RoleID = dto.RoleID;

            dto.OnEntity(entity);

            return entity;
        }
コード例 #4
0
ファイル: UserRoleAssembler.cs プロジェクト: Hardik21/JobsABA
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="UserRole"/> converted from <see cref="UserRoleDTO"/>.</param>
 static partial void OnEntity(this UserRoleDTO dto, UserRole entity);