示例#1
0
        public async Task <IActionResult> DeletePhoto(int patientId, int id)
        {
            var patient = await _repo.GetPatient(patientId);

            if (!patient.Photos.Any(p => p.Id == id))
            {
                return(Unauthorized());
            }

            var photoFromRepo = await _repo.GetPhoto(id);

            if (photoFromRepo.IsMain)
            {
                return(BadRequest("Vous ne pouvez pas supprimer votre photo proncipale"));
            }

            if (photoFromRepo.PublicId != null)
            {
                var deleteParams = new DeletionParams(photoFromRepo.PublicId);

                var result = _cloudinary.Destroy(deleteParams);

                if (result.Result == "ok")
                {
                    _repo.Delete(photoFromRepo);
                }
            }

            if (photoFromRepo.PublicId == null)
            {
                _repo.Delete(photoFromRepo);
            }

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Suppression de la photo pas possible"));
        }
示例#2
0
        public async Task <IActionResult> DeleteDocteur(int id)
        {
            var docteur = await _repo.GetDocteur(id);


            if (docteur != null)
            {
                _repo.Delete(docteur);
            }

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Suppression du docteur impossible"));
        }
示例#3
0
        public async Task <IActionResult> DeletePatient(int id)
        {
            var patient = await _repo.GetPatient(id);


            if (patient != null)
            {
                _repo.Delete(patient);
            }

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Suppression du patient impossible"));
        }