public async Task <ActionResult> Put(int id, DoctorDtoUpdate dto)
        {
            var doctor = await _repository.GetById(id);

            if (doctor == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var response = await _repository.Update(id, dto);

                if (response)
                {
                    return(NoContent());
                }
                else
                {
                    return(StatusCode(500));
                }
            }

            return(BadRequest());
        }
Пример #2
0
        public async Task <bool> Add(DoctorDtoUpdate dto)
        {
            try
            {
                var doctor = Mapper.Map <Doctor>(dto);

                await Add(doctor);

                await _doctorEspecialidadRepository.AddDoctorEspecialidades(dto.EspecialidadIds, doctor.Id);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public async Task <ActionResult> Post(DoctorDtoUpdate dto)
        {
            if (ModelState.IsValid)
            {
                var response = await _repository.Add(dto);

                if (response)
                {
                    return(NoContent());
                }
                else
                {
                    return(StatusCode(500));
                }
            }

            return(BadRequest());
        }
Пример #4
0
        public async Task <bool> Update(int id, DoctorDtoUpdate dto)
        {
            try
            {
                var doctor = await GetById(id);

                doctor.CodigoPostal    = dto.CodigoPostal;
                doctor.Correo          = dto.Correo;
                doctor.Telefono        = dto.Telefono;
                doctor.Nombre          = dto.Nombre;
                doctor.FechaNacimiento = dto.FechaNacimiento;

                await Update(doctor);

                await _doctorEspecialidadRepository.UpdateDoctorEspecialidades(dto.EspecialidadIds, doctor.Id);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }