Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
 public async Task Insert(Oldillnesshistory t)
 {
     await _context.Oldillnesshistory.AddAsync(t);
 }
Exemple #4
0
 public void Update(Oldillnesshistory t)
 {
     _context.Oldillnesshistory.Attach(t);
     _context.Entry(t).State = EntityState.Modified;
 }
Exemple #5
0
 public void Delete(Oldillnesshistory t)
 {
     _context.Oldillnesshistory.Remove(t);
 }