Esempio n. 1
0
        public void guardarOperacionesAEstilo(int[] op, int id)
        {
            var operacionesActuales = contexto.EstiloOperaciones.Where(x => x.codigoEstilo == id).ToList(); ;
            
            var lista = new List<EstiloOperacione>();
            foreach (var codigoOperacion in op)
            {
                var estiloOperacione = new EstiloOperacione();
                estiloOperacione.codigoEstilo = id;
                estiloOperacione.codigoOperacion = codigoOperacion;
                
                lista.Add(estiloOperacione);
                
            }

            contexto.EstiloOperaciones.DeleteAllOnSubmit(operacionesActuales);
            contexto.EstiloOperaciones.InsertAllOnSubmit(lista); 

            contexto.SubmitChanges();
            
        }
Esempio n. 2
0
        public  void agregarEstilo(ModelPreguntaCrearEstilo pregunta)
        {
            var vf = true;
            var estilo = new Estilo {nombreEstilo = pregunta.estilo, comentario = pregunta.comentario};

            try
            {
                contexto.Estilos.InsertOnSubmit(estilo);
                contexto.SubmitChanges();

             
            }
            catch (Exception)
            {
                vf = false;

            }
            if (vf == false) throw new Exception("Ocurrio un error al guardar estilo");

            try
            {
                if (pregunta.estiloSeleccionado > 0)
                {
                    var estiloOperaciones = contexto.EstiloOperaciones.Where(x => x.codigoEstilo == pregunta.estiloSeleccionado);
                    var lista = new List<EstiloOperacione>();
                    foreach (var estiloOperacione in estiloOperaciones)
                    {

                        var nuevo = new EstiloOperacione();
                        nuevo.codigoEstilo = estilo.codigoEstilo;
                        nuevo.codigoOperacion = estiloOperacione.codigoOperacion;
                        lista.Add(nuevo);
                    }

                    contexto.EstiloOperaciones.InsertAllOnSubmit(lista);
                    contexto.SubmitChanges();
                }


            }
            catch (Exception)
            {
                
                throw  new Exception("Ocurrio un problema al copiar estilo");
            }
            
        }
Esempio n. 3
0
        public void agregarNuevasOperacionesAEstilo(int[] op, int id)
        {
            var lista = new List<EstiloOperacione>();
            foreach (var codigoOperacion in op)
            {
                var estiloOperacione = new EstiloOperacione();
                estiloOperacione.codigoEstilo = id;
                estiloOperacione.codigoOperacion = codigoOperacion;
                lista.Add(estiloOperacione);
            }

            contexto.EstiloOperaciones.InsertAllOnSubmit(lista);
            contexto.SubmitChanges();

        }