Beispiel #1
0
        public bool Delete(int id)
        {
            bool result = false;

            try
            {
                using (var db = new DB_CRUDContext())
                {
                    var entity = db.TbEntidads.Where(d => d.IdEntidad == id).FirstOrDefault();

                    if (entity != null)
                    {
                        entity.Estato = false;

                        db.Entry <TbEntidad>(entity).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw new Exception("Ocurrio un error al eliminar los datos.");
            }
        }
        public bool Update(TaxpayerRequest entity)
        {
            bool result = false;

            try
            {
                using (var db = new DB_CRUDContext())
                {
                    var taxpayer = db.TbTipoContribuyentes.Where(d => d.IdTipoContribuyente == entity.IdContribuyente).FirstOrDefault();

                    if (taxpayer != null)
                    {
                        taxpayer.Nombre = entity.Nombre;

                        db.Entry <TbTipoContribuyente>(taxpayer).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw new Exception("Ocurrio un error al actualizar los datos.");
            }
        }
Beispiel #3
0
        public bool Update(DocumentRequest entity)
        {
            bool result = false;

            try
            {
                using (var db = new DB_CRUDContext())
                {
                    var document = db.TbTipoDocumentos.Where(d => d.IdTipoDocumento == entity.IdTipoDoc).FirstOrDefault();

                    if (document != null)
                    {
                        document.Codigo      = entity.Codigo;
                        document.Nombre      = entity.Nombre;
                        document.Descripcion = entity.Descripcion;

                        db.Entry <TbTipoDocumento>(document).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw new Exception("Ocurrio un error al actualizar los datos.");
            }
        }
        public bool Delete(int id)
        {
            bool result = false;

            try
            {
                using (var db = new DB_CRUDContext())
                {
                    var taxpayer = db.TbTipoContribuyentes.Where(d => d.IdTipoContribuyente == id).FirstOrDefault();

                    if (taxpayer != null)
                    {
                        taxpayer.Estato = false;

                        db.Entry <TbTipoContribuyente>(taxpayer).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw new Exception("Ocurrio un error al eliminar los datos.");
            }
        }
Beispiel #5
0
        public bool Update(EntityRequest entity)
        {
            bool result = false;

            try
            {
                using (var db = new DB_CRUDContext())
                {
                    var oentity = db.TbEntidads.Where(d => d.IdEntidad == entity.IdEntidad).FirstOrDefault();

                    if (oentity != null)
                    {
                        oentity.IdTipoDocumento     = entity.IdTipoDoc;
                        oentity.NroDocumento        = entity.NumDocumento;
                        oentity.RazonSocial         = entity.RazonSocial;
                        oentity.NombreComercial     = entity.NombreComercial;
                        oentity.IdTipoContribuyente = entity.IdContribuyente;
                        oentity.Direccion           = entity.Direccion;
                        oentity.Telefono            = entity.Telefono;

                        db.Entry <TbEntidad>(oentity).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw new Exception("Ocurrio un error al insertar los datos.");
            }
        }