Esempio n. 1
0
        public async Task DeleteAnimalAsync(Guid animalId)
        {
            var animal = await _animalRepository.GetAsync(animalId,
                                                          source => source
                                                          .Include(s => s.MedicalOperations)
                                                          .ThenInclude(m => m.Attachments));

            foreach (var medRow in animal.MedicalOperations)
            {
                foreach (var attachment in medRow.Attachments)
                {
                    if (!string.IsNullOrEmpty(attachment.FilePath))
                    {
                        await _attachmentBlobManager.DeleteFileAsync(attachment.FilePath);
                    }

                    _attachmentRepository.Delete(attachment);
                }

                _medicalOperationRepository.Delete(medRow);
            }

            _animalRepository.Delete(animal);

            await _unitOfWork.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task DeleteAttachmentAsync(Guid attachmentId)
        {
            var attachment = await _attachmentRepository.GetAsync(attachmentId);

            if (!string.IsNullOrEmpty(attachment.FilePath))
            {
                await _attachmentBlobManager.DeleteFileAsync(attachment.FilePath);
            }

            _attachmentRepository.Delete(attachment);

            await _unitOfWork.SaveChangesAsync();
        }
        public async Task DeleteMedicalRowAsync(Guid medicalRowId)
        {
            var medicalRow = await _medicalOperationRepository.GetAsync(medicalRowId, source => source.Include(m => m.Attachments));

            foreach (var attachment in medicalRow.Attachments)
            {
                if (!string.IsNullOrEmpty(attachment.FilePath))
                {
                    await _attachmentBlobManager.DeleteFileAsync(attachment.FilePath);
                }

                _attachmentRepository.Delete(attachment);
            }

            _medicalOperationRepository.Delete(medicalRow);

            await _unitOfWork.SaveChangesAsync();
        }