Exemplo n.º 1
0
        public void Delete(int id)
        {
            try
            {
                var categoriaExistente = _categoriaRepository.Get(id);
                if (categoriaExistente == null)
                {
                    Notification.SetNotification("Categoria", "Categoria não encontrada");
                    return;
                }

                var filmes = _filmeRepository.Get();
                if (filmes.Any(x => x.Categoria.CategoriaId == id))
                {
                    Notification.SetNotification("Categoria", "Não foi possível excluir a Categoria, pois está relacionada à um Filme");
                    return;
                }

                _categoriaRepository.Delete(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public async Task <Notification> Executar(int categoriaId)
        {
            _notification.Errors.Clear();

            Categoria entity = _repository.GetSingle(categoriaId);

            Validate(entity);

            if (_notification.HasErrors == true)
            {
                return(_notification);
            }

            _repository.Delete(entity);

            try
            {
                await _repository.SaveAsync();
            }
            catch (Exception ex)
            {
                _notification.Errors.Add(ex.Message);
            }

            return(_notification);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> DeleteCategoria(int id)
        {
            if (!_repository.Exists(id).Result)
            {
                return(NotFound());
            }
            await _repository.Delete(id);

            return(RedirectToAction(nameof(GetAllCategorias)));
        }
Exemplo n.º 4
0
        public void Delete(int id)
        {
            if (id == 0)
            {
                throw new CustomException("Categoria Inexistente!");
            }

            var delet = _categoriaRepository.GetById(id);

            _categoriaRepository.Delete(delet);
            _categoriaRepository.Save();
        }
Exemplo n.º 5
0
        public void ExcluirCategoria(int id)
        {
            Categoria categoria = categoriaRepository.GetById(id);

            categoria.Excluir(categoriaValidator);

            unitOfWork.BeginTransaction();

            categoriaRepository.Delete(id);

            unitOfWork.Commit();
        }
 public IActionResult Delete(string id)
 {
     if (ModelState.IsValid)
     {
         _categoriaRepository.Delete(id);
         return(Ok(new { data = "Deletado" }));
     }
     else
     {
         return(BadRequest(new { error = "Request inválido" }));
     }
 }
Exemplo n.º 7
0
        public async Task <CategoriaEntity> Delete(int id)
        {
            var categoria = await _repository.GetById(id);

            if (categoria == null)
            {
                throw new ArgumentException("Id inexistente.");
            }
            categoria.Delete();
            await _repository.Delete(categoria);

            return(categoria);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Delete(int id)
        {
            var data = await _categoriaRepository.GetAsync(id);

            if (data == null)
            {
                return(BadRequest(new { Categoria = new string[] { "Categoria não encontrada." } }));
            }

            _categoriaRepository.Delete(data);

            return(Ok());
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Excluir(int Id)
        {
            var cat = await _categoriaRepository.GetAsync(Id);

            if (cat == null)
            {
                return(BadRequest());
            }

            _categoriaRepository.Delete(cat);
            await _uow.CommitAsync();

            return(NoContent());
        }
        public async Task <IActionResult> Delete(int id)
        {
            var data = await _catRepository.GetAsync(id);

            if (data == null)
            {
                return(BadRequest("Essa categoria não existe"));
            }

            _catRepository.Delete(data);
            await _uow.CommitAsync();

            return(NoContent());
        }
Exemplo n.º 11
0
        public ActionResult Delete(int id)
        {
            var perfil = _compraRepository.GetCompraByCategoria(id).Count();

            if (perfil != 0)
            {
                return(BadRequest("Impossivel excluir categorias já referenciadas."));
            }
            else
            {
                _categoriaRepository.Delete(id);
                return(Ok());
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Delete(int id)
        {
            var data = await _categRepo.GetAsync(id);

            if (data == null)
            {
                return(BadRequest(new { error = "Categoria não localizada" }));
            }

            _categRepo.Delete(data);
            await _uow.CommitAsync();

            return(NoContent());
        }
Exemplo n.º 13
0
        public ActionResult Delete(int id)
        {
            var existe = _categoriaRepositor.Get(id);

            if (existe != null)
            {
                var podeExcluir = _categoriaRepositor.PodeExcluir(id);
                if (podeExcluir)
                {
                    _categoriaRepositor.Delete(id);
                    return(new OkResult());
                }
            }
            return(new NotFoundResult());
        }
Exemplo n.º 14
0
        public void CategoriaRepository_InsertEGetAllEDelete()
        {
            var categoriaTeste = new Categoria
            {
                Descricao = "CATEGORIA TESTE UNITÁRIO"
            };

            _categoriaRepository.Insert(categoriaTeste);
            _unitOfWork.Persist();

            var todasAsCategorias = _categoriaRepository.GetAll().ToList();

            Assert.True(todasAsCategorias != null && todasAsCategorias.Any());

            _categoriaRepository.Delete(categoriaTeste);
        }
Exemplo n.º 15
0
            public async Task <Unit> Handle(RunDelete request, CancellationToken cancellationToken)
            {
                var categoria = await _categoriaRepository.Get(request.CategoriaId);

                if (categoria == null)
                {
                    throw new ManejadorError(HttpStatusCode.NoContent, new { mensaje = "La categoria no existe" });
                }

                var result = await _categoriaRepository.Delete(request.CategoriaId);

                if (result > 0)
                {
                    return(Unit.Value);
                }

                throw new Exception("No se pudo Eliminar la Categoria");
            }
        public async Task <IActionResult> Delete(int id)
        {
            var categoria = await _categoriaRepository.GetAsync(id);

            if (categoria == null)
            {
                ModelState.AddModelError("Id", "Categoria não encontrada");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _categoriaRepository.Delete(categoria);

            return(Ok());
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var item = await Repository.GetById(id);

                if (item == null)
                {
                    return(BadRequest("El ID: " + id + " No existe, Vuela a ingresar otro ID."));
                }

                await Repository.Delete(id);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Delete(int id)
        {
            var data = await _categoriaRepository.GetByIdAsync(id);

            if (data == null)
            {
                return(NotFound("Categoria não encontrada"));
            }

            _categoriaRepository.Delete(data);

            if (await _categoriaRepository.CommitAsync())
            {
                return(Ok());
            }
            else
            {
                return(BadRequest("Falha ao excluir categoria"));
            }
        }
Exemplo n.º 19
0
        public ActionConfirmation DeleteCategoria(Guid id)
        {
            var item = _categoriaRepository.Get(id);

            if (item == null)
            {
                return(ActionConfirmation.CreateFailure("objeto no existe"));
            }

            try
            {
                _categoriaRepository.Delete(item.Id);
                _categoriaRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("Delete OK (" + item.Nombre + ")"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.EliminarObjeto.ToString(), exception, item.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemplo n.º 20
0
 public Task <string> Delete(int id)
 {
     return(_repository.Delete(id));
 }
Exemplo n.º 21
0
 public void Delete(int id)
 {
     crep.Delete(id);
 }
Exemplo n.º 22
0
 public bool Delete(int id)
 {
     return(categoriaRepository.Delete(id));
 }
Exemplo n.º 23
0
 public void Delete(Categoria categoria)
 {
     _categoriaRepository.Delete(categoria);
 }
Exemplo n.º 24
0
 public int Delete(CategoriaViewModel viewModel, IDbTransaction transaction = null)
 {
     return(_categoriaRepository.Delete(_mapper.Map <Categoria>(viewModel), transaction: transaction));
 }
Exemplo n.º 25
0
        public void Delete(int id)
        {
            var categoria = _categoriaRepository.Get(id);

            _categoriaRepository.Delete(categoria);
        }
Exemplo n.º 26
0
 public IHttpActionResult Delete(int Num_IDCategoria)
 {
     _categoriaRepository.Delete(Num_IDCategoria);
     return(Ok());
 }
Exemplo n.º 27
0
 public bool Delete(int id)
 {
     return(_repository.Delete(id));
 }
Exemplo n.º 28
0
 public void Delete(int id)
 {
     categoriaRepo.Delete(id);
 }
 public void Delete(Categoria obj)
 {
     categoriaRepository.Delete(obj);
 }
Exemplo n.º 30
0
 public void Delete(Guid IdCategoria)
 {
     repository.Delete(IdCategoria);
 }