Esempio n. 1
0
        public static bool EditPersona(PERSONA Persona)
        {
            using (FidelEntities db = new FidelEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try {
                        if (Persona.GRUPO_FAMILIAR.Count() > 0)
                        {
                            db.GRUPO_FAMILIAR.AddRange(Persona.GRUPO_FAMILIAR);
                        }
                        db.Entry(Persona).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        transaction.Commit();
                        return(true);
                    }

                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        return(false);

                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
 public static PARENTESCO FindParentesco(long?id)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
             return(db.PARENTESCO.Find(id));
     }
     catch (Exception)
     {
         return(new PARENTESCO());
     }
 }
Esempio n. 3
0
 public static PERSONA FindPersona(long?id)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             return(db.PERSONA.Include("GRUPO_FAMILIAR.PARENTESCO").Where(x => x.ID_PERSONA == id).FirstOrDefault());
         }
     }
     catch (Exception)
     {
         return(new PERSONA());
     }
 }
Esempio n. 4
0
 public static IEnumerable <PERSONA> GetAll()
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             return(db.PERSONA.Where(x => x.Activo == true).ToList());
         }
     }
     catch (Exception ex)
     {
         return(new List <PERSONA>());
     }
 }
 public static GRUPO_FAMILIAR Find(long?id)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.Configuration.ProxyCreationEnabled = false;
             return(db.GRUPO_FAMILIAR.Find(id));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static IEnumerable <GRUPO_FAMILIAR> GetAll(Expression <System.Func <GRUPO_FAMILIAR, bool> > function)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.Configuration.ProxyCreationEnabled = false;
             return(db.GRUPO_FAMILIAR.Where(function).ToList());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 7
0
 public static void EditParentesco(PARENTESCO Parentesco)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.Entry(Parentesco).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 8
0
 public static bool Create(PERSONA Persona)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.PERSONA.Add(Persona);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public static bool Save(List <GRUPO_FAMILIAR> GrupoFamiliar)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.GRUPO_FAMILIAR.AddRange(GrupoFamiliar);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 10
0
 public static bool Create(PARENTESCO Parentesco)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.PARENTESCO.Add(Parentesco);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public static bool Delete(List <long> GrupoFamiliar)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             var datos = db.GRUPO_FAMILIAR.Where(x => GrupoFamiliar.Contains(x.ID_GRUPO_FAMILIAR));
             db.GRUPO_FAMILIAR.RemoveRange(datos);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 12
0
 public static IEnumerable <PARENTESCO> GetAll(Expression <Func <PARENTESCO, bool> > exp)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
             var datos = db.PARENTESCO.Where(exp).ToList();
             db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
             return(datos);
         }
     }
     catch (Exception)
     {
         return(new List <PARENTESCO>());
     }
 }
Esempio n. 13
0
 public static void DeleteParentesco(long?id)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             PARENTESCO Parentesco = FindParentesco(id);
             if (Parentesco != null)
             {
                 db.PARENTESCO.Remove(Parentesco);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 14
0
 public static void DeletePersona(long?id)
 {
     try
     {
         using (FidelEntities db = new FidelEntities())
         {
             PERSONA Persona = FindPersona(id);
             if (Persona != null)
             {
                 db.GRUPO_FAMILIAR.Where(x => Persona.ID_PERSONA == x.ID_PERSONA).Update(x => new GRUPO_FAMILIAR()
                 {
                     Activo = false
                 });
                 Persona.Activo          = false;
                 db.Entry(Persona).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }