public async Task <ActionResult <Oldmedicinehistory> > PostOldmedicinehistory(Oldmedicinehistory oldmedicinehistory) { if (!_patientsRepository.Exists(oldmedicinehistory.PatientId)) { return(NotFound(NotFoundEmptyJsonResult)); } if (!await _authorizationService.CanUserAccessPatientData(oldmedicinehistory.PatientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } if (await OldmedicinehistoryExists(oldmedicinehistory.MedicineId, oldmedicinehistory.PatientId, oldmedicinehistory.Date)) { return(Conflict()); } try { await _repository.Insert(oldmedicinehistory); await _repository.Save(); } catch (DbUpdateException e) { return(StatusCode(500, InternalServerErrorJsonResult(e.Message))); } return(Created("", oldmedicinehistory)); }
public async Task <IActionResult> PutOldmedicinehistory(decimal patientId, decimal medicineId, DateTime date, Oldmedicinehistory oldmedicinehistory) { if (patientId != oldmedicinehistory.PatientId || medicineId != oldmedicinehistory.MedicineId && date != oldmedicinehistory.Date) { return(BadRequest(BadRequestEmptyJsonResult)); } if (!await OldmedicinehistoryExists(oldmedicinehistory.MedicineId, oldmedicinehistory.PatientId, oldmedicinehistory.Date)) { return(NotFound(NotFoundEmptyJsonResult)); } if (!await _authorizationService.CanUserAccessPatientData(patientId, this)) { return(Unauthorized(UnauthorizedEmptyJsonResult)); } try { _repository.Update(oldmedicinehistory); await _repository.Save(); } catch (DbUpdateConcurrencyException e) { return(StatusCode(500, InternalServerErrorJsonResult(e.Message))); } return(Ok(OkEmptyJsonResult)); }
public async Task Insert(Oldmedicinehistory t) { await _context.Oldmedicinehistory.AddAsync(t); }
public void Update(Oldmedicinehistory t) { _context.Oldmedicinehistory.Attach(t); _context.Entry(t).State = EntityState.Modified; }
public void Delete(Oldmedicinehistory t) { _context.Oldmedicinehistory.Remove(t); }