public IHttpActionResult PutClassType(int id, ClassType classType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != classType.ClassTypeID) { return BadRequest(); } db.Entry(classType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClassTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public ClassType CreateClassType(ClassType classType) { db.ClassTypes.Add(classType); db.SaveChanges(); return classType; }
public IHttpActionResult PostClassType(ClassType classType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ClassTypes.Add(classType); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = classType.ClassTypeID }, classType); }
public void UpdateClassType(int id, ClassType classType) { db.Entry(classType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } }
/// <summary> /// Converts this instance of <see cref="ClassTypeDTO"/> to an instance of <see cref="ClassType"/>. /// </summary> /// <param name="dto"><see cref="ClassTypeDTO"/> to convert.</param> public static ClassType ToEntity(this ClassTypeDTO dto) { if (dto == null) return null; var entity = new ClassType(); entity.ClassTypeID = dto.ClassTypeID; entity.Name = dto.Name; entity.Code = dto.Code; entity.Description = dto.Description; dto.OnEntity(entity); return entity; }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="ClassType"/> converted from <see cref="ClassTypeDTO"/>.</param> static partial void OnEntity(this ClassTypeDTO dto, ClassType entity);