public async Task <IActionResult> Delete(int id)
        {
            var value = await repository.GetValue(id);

            if (value != null)
            {
                var questions = await repository.GetQuestionsFromValues(id);

                foreach (var question in questions)
                {
                    repository.Delete(question);
                }

                var photos = value.Photos.ToList();
                foreach (var photo in photos)
                {
                    await DeletePhoto(photo);
                }

                repository.Delete(value);
            }

            await context.SaveChangesAsync();

            return(Ok(value));
        }
Beispiel #2
0
 public void Delete(int id)
 {
     if (id < 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     _valueRepository.Delete(id);
 }
Beispiel #3
0
        public async Task DeleteValueByIdAsync(Guid id)
        {
            var value = await _valueRepository.GetById(id);

            if (value == null)
            {
                return;
            }

            await _valueRepository.Delete(value);
        }
        public async Task <IActionResult> DeletePhoto(int valueId, int id)
        {
            var value = await repository.GetValue(valueId);

            if (!value.Photos.Any(p => p.Id == id))
            {
                return(NotFound("Brak zdjęcia o takim id"));
            }

            var photo = await repository.GetPhoto(id);

            if (photo.IsMain)
            {
                return(BadRequest("To zdjęcie już jest główne"));
            }

            if (photo.public_id != null)
            {
                var destroyParams = new DeletionParams(photo.public_id);
                var result        = cloudinary.Destroy(destroyParams);
                if (result.Result == "ok")
                {
                    repository.Delete(photo);
                }
            }

            if (photo.public_id == null)
            {
                repository.Delete(photo);
            }

            if (await repository.SaveAll())
            {
                return(Ok(photo));
            }

            return(BadRequest("Nie udało się usunąć"));
        }
        public async Task <ActionResult> Delete(Guid id)
        {
            var value = await _valueRepository.GetById(id);

            if (value is null)
            {
                return(NotFound());
            }

            _valueRepository.Delete(value);
            await _valueRepository.UnitOfWork.Commit();

            return(Ok());
        }
        public IActionResult Remove(int id)
        {
            Value item = _valueRepository.GetSingle(id);

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

            _valueRepository.Delete(id);

            if (!_valueRepository.Save())
            {
                throw new Exception("Deleting an item failed on save.");
            }

            return(NoContent());
        }
Beispiel #7
0
 public async Task Delete(Guid valueId)
 {
     await repo.Delete(valueId);
 }
Beispiel #8
0
 public async Task Delete(Guid crazyKey)
 {
     await repo.Delete(crazyKey);
 }
Beispiel #9
0
 public void Delete(int id)
 {
     _valueRepository.Delete(id);
 }
 public async Task Delete(KeyEnum valueId)
 {
     await repo.Delete(valueId);
 }
Beispiel #11
0
 public async Task Delete(Int32 valueId)
 {
     await repo.Delete(valueId);
 }
        public async Task Delete(int id)
        {
            await _repository.Delete(id);

            _logger.LogDebug("Deleted value with id {id}", id);
        }
Beispiel #13
0
 public async Task Delete(String valueId)
 {
     await repo.Delete(valueId);
 }