示例#1
0
        public bool Eliminar(string Ruc)
        {
            if (!String.IsNullOrWhiteSpace(Ruc))//EVALUO CAMPOS OBLIGATORIOS
            {
                if (proveedorRepository.Exists(Ruc))
                {
                    bool resultp = true;
                    PersonaRepository personaRepository = new PersonaRepository();
                    if (proveedorRepository.HasRepresent(Ruc, out string DniRepresent))
                    {
                        resultp = personaRepository.Delete(DniRepresent);
                    }
                    var result = proveedorRepository.Delete(Ruc);

                    //if (result) listaClientes.Remove(listaClientes.FirstOrDefault(x => x.Ruc == Ruc));

                    return(result && resultp);
                }
                else
                {
                    throw new Exception(ExceptionMessageManager.ExceptionMessageProveedor.DoesNotExist(Ruc));
                }
            }
            else
            {
                throw new Exception(ExceptionMessageManager.ExceptionMessageVehiculo.KeyIsNull());
            }
        }
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                if (id < 1)
                {
                    return(BadRequest());
                }
                var isExists = await _proveedorRepository.isExists(id);

                if (!isExists)
                {
                    return(NotFound());
                }
                var proveedor = await _proveedorRepository.FindById(id);

                var isSuccess = await _proveedorRepository.Delete(proveedor);

                if (!isSuccess)
                {
                    return(InternalError("Error al eliminar registro"));
                }
                return(NoContent());
            }
            catch (Exception e)
            {
                return(InternalError($"{e.Message} - {e.InnerException}"));
            }
        }
 public ActionResult DeleteItem(int id)
 {
     try
     {
         var proveedor = _proveedorRepository.GetById(id);
         _proveedorRepository.Delete(proveedor);
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View("Index"));
     }
 }
示例#4
0
 /// <summary>
 /// Elimina el proveedor seleccionado
 /// </summary>
 /// <param name="proveedor"></param>
 public void EliminarProveedor(Proveedor proveedor)
 {
     try
     {
         Proveedor temp = _proveedorRepository.Find(proveedor.Id);
         if (temp == null)
         {
             ThrowExceptionProveedor("El proveedor a eliminar no existe");
         }
         _proveedorRepository.Delete(proveedor);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
            public async Task <Unit> Handle(RunDelete request, CancellationToken cancellationToken)
            {
                var proveedor = await _proveedorRepository.Get(request.ProveedorId);;

                if (proveedor == null)
                {
                    throw new ManejadorError(HttpStatusCode.NotFound, new { mensaje = "No se encontro el proveedor" });
                }

                var result = await _proveedorRepository.Delete(request.ProveedorId);

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

                throw new Exception("No se pudo Eliminar el Proveedor");
            }