Example #1
0
        public void GuardarJefatura(Jefatura entidad)
        {
            DataBaseModelContext db = new DataBaseModelContext();

            try
            {
                entidad.Descripcion = entidad.Descripcion.ToUpper();
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                //TODO: Cambiar habilitado por el embebido
                entidad.Habilitado = true;
                if (entidad.Id == 0)
                {
                    db.Jefatura.AddObject(entidad);
                }
                else
                {
                    Jefatura tmpJefatura = db.Jefatura.SingleOrDefault(s => s.Id == entidad.Id);
                    if (tmpJefatura == null)
                    {
                        return;
                    }
                    tmpJefatura.Descripcion = entidad.Descripcion;
                    tmpJefatura.Habilitado  = entidad.Habilitado;
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception((ex.InnerException).Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Example #2
0
 public void GuardarJefatura(Jefatura entidad)
 {
     try
     {
         using (BusinessOrganizacion negocio = new BusinessOrganizacion())
         {
             negocio.GuardarJefatura(entidad);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }