public IHttpActionResult PutRole(int id, Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != role.RoleID) { return BadRequest(); } try { db.UpdateRole(id, role); } catch (DbUpdateConcurrencyException) { if (!RoleExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public Role CreateRole(Role role) { db.Roles.Add(role); db.SaveChanges(); return role; }
public Role Create(Role oRole) { if (oRole != null) { return oRoleRepos.CreateRole(oRole); } return null; }
public IHttpActionResult PostRole(Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CreateRole(role); return CreatedAtRoute("DefaultApi", new { id = role.RoleID }, role); }
public void UpdateRole(int id, Role role) { db.Entry(role).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } }
/// <summary> /// Converts this instance of <see cref="RoleDTO"/> to an instance of <see cref="Role"/>. /// </summary> /// <param name="dto"><see cref="RoleDTO"/> to convert.</param> public static Role ToEntity(this RoleDTO dto) { if (dto == null) return null; var entity = new Role(); entity.RoleID = dto.RoleID; entity.Name = dto.Name; entity.Precedence = dto.Precedence; dto.OnEntity(entity); return entity; }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="Role"/> converted from <see cref="RoleDTO"/>.</param> static partial void OnEntity(this RoleDTO dto, Role entity);