Beispiel #1
0
        public async Task <HttpResponseMessage> Delete()
        {
            try
            {
                ServiceData.Models.User found = _userRepository.Search(u => u.Email == User.Identity.Name).FirstOrDefault();
                if (found == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
                if (found.Email != User.Identity.Name)
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden));
                }

                // Delete all conditions and photos from DB and storage
                foreach (ServiceData.Models.UserCondition condition in found.Conditions)
                {
                    await UserConditionsController.Delete(_conditionRepository, _shareRepository, _photoRepository, condition.Id);
                }

                PostLog("Users_Delete", found.Id);

                await _userRepository.Delete(found.Id);

                ServerUtils.LogTelemetryEvent(User.Identity.Name, "DeleteUser");

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
        public async Task <HttpResponseMessage> Delete(int studyId)
        {
            ServiceData.Models.StudyEnrolment found = _studyEnrolmentRepository.Search(
                en => en.User.Email == User.Identity.Name &&
                en.StudyId == studyId
                ).FirstOrDefault();

            if (found != null)
            {
                await _studyEnrolmentRepository.Delete(found.Id);
            }

            ServerUtils.LogTelemetryEvent(User.Identity.Name, "DeleteShare");
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Beispiel #3
0
        public async Task <HttpResponseMessage> Delete(int id)
        {
            ServiceData.Models.Share found = _shareRepository.GetById(id);

            if (found == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            if (found.Owner.Email != User.Identity.Name)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }

            await _shareRepository.Delete(id);

            ServerUtils.LogTelemetryEvent(User.Identity.Name, "DeleteShare");
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        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);
        }
        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);
        }
 public async Task <ActionResult> Delete(string key)
 {
     return(await base.HandleDelete(key, id => _repository.Get(id), model => _repository.Delete(model)));
 }
Beispiel #7
0
 public void Delete(Guid id)
 {
     _productionRepository.Delete(_productionRepository.GetById(id));
 }
 public void Delete(VirtualMachine virtualMachine)
 {
     _virtualMachineRepository.Delete(virtualMachine);
 }