public async Task <ActionResult <Oldillnesshistory> > PostOldillnesshistory(Oldillnesshistory oldillnesshistory) { if (!_patientsRepository.Exists(oldillnesshistory.PatientId)) { return(NotFound(NotFoundEmptyJsonResult)); } if (!await _authorizationService.CanUserAccessPatientData(oldillnesshistory.PatientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } if (await OldillnesshistoryExists(oldillnesshistory.IllnessId, oldillnesshistory.PatientId)) { return(Conflict(ConflictJsonResult("Old illness history with that illness and patient already exists"))); } try { await _repository.Insert(oldillnesshistory); await _repository.Save(); } catch (DbUpdateException e) { return(StatusCode(500, InternalServerErrorJsonResult(e.Message))); } return(Created("", oldillnesshistory)); }
public async Task <IActionResult> PutOldillnesshistory(decimal patientId, decimal illnessId, Oldillnesshistory oldillnesshistory) { if (illnessId != oldillnesshistory.IllnessId || patientId != oldillnesshistory.PatientId) { return(BadRequest(BadRequestEmptyJsonResult)); } if (!await OldillnesshistoryExists(oldillnesshistory.IllnessId, oldillnesshistory.PatientId)) { return(NotFound(NotFoundEmptyJsonResult)); } if (!await _authorizationService.CanUserAccessPatientData(patientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } try { _repository.Update(oldillnesshistory); await _repository.Save(); } catch (DbUpdateConcurrencyException e) { return(StatusCode(500, InternalServerErrorJsonResult(e.Message))); } return(Ok(OkEmptyJsonResult)); }
public async Task Insert(Oldillnesshistory t) { await _context.Oldillnesshistory.AddAsync(t); }
public void Update(Oldillnesshistory t) { _context.Oldillnesshistory.Attach(t); _context.Entry(t).State = EntityState.Modified; }
public void Delete(Oldillnesshistory t) { _context.Oldillnesshistory.Remove(t); }