public async Task <ActionResult> AddVaccine(int patientId, [FromBody] VaccineDto vaccine)
        {
            vaccine.PatientId = patientId;
            var res = await vaccineService.AddAsync(vaccine);

            return(Created($"/api/patient/{patientId}/vaccine/{res.Id}", res));
        }
Ejemplo n.º 2
0
        public async Task <VaccineDto> GetVaccineAsync(int id)
        {
            Vaccine vaccine = await _vaccineRepo.GetAsync(id);

            VaccineDto result = _mapper.Map <VaccineDto>(vaccine);

            return(result);
        }
        public async Task <ActionResult> Put(int patientId, int vaccineId, [FromBody] VaccineDto vaccine)
        {
            // Вдруг забудут =)
            vaccine.Id        = vaccineId;
            vaccine.PatientId = patientId;

            var res = await vaccineService.UpdateAsync(
                vaccine,
                x => x.Id == vaccine.Id && x.PatientId == vaccine.PatientId);

            return(CheckForNullAndReturnOkOrNotFound(res));
        }