Exemplo n.º 1
0
        private void InsertParametriDefault()
        {
            var lista = new[]
            {
                new { n = Tipologiche.Parametro.PMAX_HR_DISCREZIONALI, v = 20 },
                new { n = Tipologiche.Parametro.PMAX_HR_COMPORTAMENTALI, v = 30 },
                new { n = Tipologiche.Parametro.PMAX_COMPORTAMENTALI, v = 20 },
                new { n = Tipologiche.Parametro.PMAX_TECN_STRATEGIC, v = 12 },   //40% di 30
                new { n = Tipologiche.Parametro.PMAX_TECN_COMPETITIVE, v = 18 }, //60% di 30
                new { n = Tipologiche.Parametro.PERCENTUALE_SOGLIA_FOUNDATIONAL, v = 70 },
            };

            //var repos = ServiceLocator.Current.GetInstance<IRepository<Parametro>>();
            //var uow = ServiceLocator.Current.GetInstance<IUnitOfWork>();

            foreach (var elemento in lista)
            {
                context.Parametri.Add(new Parametro()
                {
                    Nome   = elemento.n,
                    Valore = elemento.v.ToString()
                });
            }

            context.SaveChanges();
        }
Exemplo n.º 2
0
        private Dipendente SalvaDipendente(D[] lista, string matricola, string cognome, string nome, string ruolo)
        {
            /*var reposDipendenti = ServiceLocator.Current.GetInstance<IRepository<Dipendente>>();
             *
             * var reposComp = ServiceLocator.Current.GetInstance<IRepository<Competenza>>();
             * var reposLivelli = ServiceLocator.Current.GetInstance<IRepository<LivelloConoscenza>>();
             * var uow = ServiceLocator.Current.GetInstance<IUnitOfWork>();*/

            /*var reposDipendenti = new BaseRepository<Dipendente>(context);
             * var reposRuoli = new BaseRepository<Ruolo>(context);
             * var reposComp = new BaseRepository<Competenza>(context);
             * var reposLivelli = new BaseRepository<LivelloConoscenza>(context);
             * var uow = new UnitOfWork(context);*/

            List <ConoscenzaCompetenza> conoscenze = new List <ConoscenzaCompetenza>();

            foreach (var elemento in lista)
            {
                ConoscenzaCompetenza conoscenza = new ConoscenzaCompetenza();
                conoscenza.Competenza        = context.Competenze.Single(c => c.Titolo == elemento.t && c.TipologiaCompetenza.MacroGruppo == elemento.mg);
                conoscenza.LivelloConoscenza = context.LivelliConoscenza.Single(lc => lc.Titolo == elemento.v);
                conoscenze.Add(conoscenza);
            }

            var dipendente = new Dipendente()
            {
                Matricola  = matricola,
                Cognome    = cognome,
                Nome       = nome,
                Conoscenze = conoscenze
            };

            dipendente.RuoloInAziendaId = context.Ruoli.Single(r => r.Titolo == ruolo).Id;


            if (context.Dipendenti.SingleOrDefault(d => d.Cognome == dipendente.Cognome) == null)
            {
                context.Dipendenti.Add(dipendente);
                //uow.Commit();
                context.SaveChanges();
            }

            return(dipendente);
        }