示例#1
0
        public void test_EventoCompleto()
        {
            int numev;
            int id_az;

            int[] id_dip = new int[2];
            int   id_ev;

            EVENTOBLL ev = new EVENTOBLL();

            dsmaddant.EVENTODataTable t;
            t     = ev.GetEVENTI();
            numev = t.Rows.Count;

            AZIENDABLL az = new AZIENDABLL();

            id_az = az.AddAZIENDA(0, "Fornitore s.r.l");
            Assert.IsTrue(id_az > 0);

            DIPENDENTIBLL di = new DIPENDENTIBLL();

            id_dip[0] = di.AddDIPENDENTI(0, id_az, "Dipendente 1");
            id_dip[1] = di.AddDIPENDENTI(0, id_az, "Dipendente 2");
            Assert.IsTrue(id_dip[0] > 0);
            Assert.IsTrue(id_dip[1] > id_dip[0]);

            id_ev = ev.AddEVENTO(0, id_az, DateTime.Now.Date, new TimeSpan(8, 0, 0), new TimeSpan(17, 0, 0));
            Assert.IsTrue(id_ev > 0);


            EVENTO_PARTECIPANTIBLL ep = new EVENTO_PARTECIPANTIBLL();

            ep.AddEVENTO_PARTECIPANTI(id_ev, id_dip[0]);
            ep.AddEVENTO_PARTECIPANTI(id_ev, id_dip[1]);

            t = ev.GetEVENTI();// legge il numero di eventi per verificare che sia aumentato di 1

            Assert.AreEqual(t.Rows.Count, numev + 1);
        }
示例#2
0
        // POST api/<controller>
        //public void Post([FromBody] string value)
        public void Post(JObject eventoCompleto)
        {
            int      id_az;
            int      id_dip;
            int      id_ev;
            DateTime dataEvento;

            try
            {
                dataEvento = DateTime.ParseExact(eventoCompleto["data"].ToString(), "d/M/yyyy", CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                Utils.RaiseBllError("Data non valida");
                return;
            }



            using (TransactionScope scope = new TransactionScope())
            {
                EVENTOBLL ev = new EVENTOBLL();



                AZIENDABLL az = new AZIENDABLL();
                id_az = az.AddAZIENDA(0, eventoCompleto["azienda"].ToString());
                if (id_az <= 0)
                {
                    return;
                }


                id_ev = ev.AddEVENTO(0, id_az,
                                     dataEvento,
                                     new TimeSpan(8, 0, 0), new TimeSpan(17, 0, 0));
                if (id_ev <= 0)
                {
                    return;
                }

                EVENTO_PARTECIPANTIBLL ep = new EVENTO_PARTECIPANTIBLL();

                foreach (var p in eventoCompleto["partecipanti"]["partecipanti"])
                {
                    if ((p != null) && (p.HasValues))  //può essere stato eliminato
                    {
                        DIPENDENTIBLL di = new DIPENDENTIBLL();
                        id_dip = di.AddDIPENDENTI(0, id_az, p["nome"].ToString());
                        if (id_dip <= 0)
                        {
                            return;
                        }
                        ep.AddEVENTO_PARTECIPANTI(id_ev, id_dip);
                    }
                }



                scope.Complete();
            }
        }