示例#1
0
        public async Task <Result> Delete(PatientsDto patient)
        {
            var data   = _mapper.Map <Patient>(patient);
            var result = await _dbContext.PatientRepository.Delete(data);

            return(result);
        }
示例#2
0
        public async Task <IActionResult> PartiallyUpdate([FromBody] PatientsDto patchDoc)
        {
            if (patchDoc == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _patientBusness.Update(patchDoc);

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> Insert([FromBody] PatientsDto patient)
        {
            if (patient == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _patientBusness.Insert(patient);

            return(CreatedAtRoute("GetById", new { id = result.Id }, patient));
        }
示例#4
0
        public PatientsDto PostPatients(PatientsDto patientsDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var patient = Mapper.Map <PatientsDto, Patients>(patientsDto);

            _context.Patients.Add(patient);
            _context.SaveChanges();

            patientsDto.PatientId = patient.PatientId;

            return(patientsDto);
        }
示例#5
0
        public void PutPatients(int userId, PatientsDto patientsDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var patient = _context.Patients.SingleOrDefault(p => p.UserId == userId);

            if (patient == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            Mapper.Map(patientsDto, patient);

            _context.SaveChanges();
        }
示例#6
0
        public async Task <IActionResult> Update(int id,
                                                 [FromBody] PatientsDto patient)
        {
            if (!await _patientBusness.CheckIfExist(id))
            {
                return(BadRequest());
            }

            if (patient == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _patientBusness.Update(patient);

            return(NoContent());
        }