public static async Task Delete(IReadWriteRepository <ServiceData.Models.UserCondition> conditionRep, IReadWriteRepository <ServiceData.Models.Share> shareRep, IReadWriteRepository <ServiceData.Models.Photo> photoRep, int id)
        {
            ServiceData.Models.UserCondition found = conditionRep.GetById(id);
            if (found == null)
            {
                return;
            }

            ServiceData.Models.Share[] foundShares = shareRep.Search(sh => sh.UserCondition.Id == found.Id).ToArray();
            foreach (ServiceData.Models.Share share in foundShares)
            {
                await shareRep.Delete(share.Id);
            }

            CloudBlobContainer container = await UploadController.GetBlobContainer();

            foreach (ServiceData.Models.Photo photo in found.Photos)
            {
                await PhotoController.Delete(photoRep, photo.Id);
            }

            await conditionRep.Delete(id);
        }
Example #2
0
        public static async Task Delete(IReadWriteRepository <ServiceData.Models.Photo> photoRep, int id)
        {
            ServiceData.Models.Photo found = photoRep.GetById(id);

            CloudBlobContainer container = await UploadController.GetBlobContainer();

            try
            {
                string url      = UploadController.GetFilePathFromUrl(found.Url);
                var    mainBlob = container.GetBlockBlobReference(url);
                mainBlob.Delete();
            }
            catch { }

            try
            {
                string thumbUrl  = UploadController.GetFilePathFromUrl(found.ThumbUrl);
                var    thumbBlob = container.GetBlockBlobReference(thumbUrl);
                thumbBlob.Delete();
            }
            catch { }

            await photoRep.Delete(id);
        }