public async Task<IHttpActionResult> PostPersonalInfo(PersonalInfo entity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _unitOfWork.PersonalInfoRepository.Insert(entity); try { await _unitOfWork.SaveChangesAsync(); } catch (UpdateException) { if (_unitOfWork.PersonalInfoRepository.Find(entity.PersonalInfoId) == null) { return Conflict(); } throw; } await _unitOfWork.PersonalInfoRepository.LoadRelatedEntitiesAsync(entity); entity.AcceptChanges(); return CreatedAtRoute("DefaultApi", new { id = entity.PersonalInfoId }, entity); }
public async Task<IHttpActionResult> PutPersonalInfo(PersonalInfo entity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _unitOfWork.PersonalInfoRepository.Update(entity); try { await _unitOfWork.SaveChangesAsync(); } catch (UpdateConcurrencyException) { if (_unitOfWork.PersonalInfoRepository.Find(entity.PersonalInfoId) == null) { return Conflict(); } throw; } await _unitOfWork.PersonalInfoRepository.LoadRelatedEntitiesAsync(entity); entity.AcceptChanges(); return Ok(entity); }