예제 #1
0
        public async Task <IActionResult> PutGare(int id, Gare gare)
        {
            if (id != gare.Id)
            {
                return(BadRequest());
            }

            _context.Entry(gare).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GareExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <Gare> > PostGare(Gare gare)
        {
            _context.Gares.Add(gare);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGare", new { id = gare.Id }, gare));
        }
예제 #3
0
    protected void cbRegistrati_Click(object sender, EventArgs e)
    {
        id = Session["iduser"] != null?Int32.Parse(Session["iduser"].ToString()) : -1;

        if (id >= 0)
        {
            utente.cercaid(id);                  // mi assicuro di leggere abilitato e pwd (quei dati che non chiedo a video)
        }
        // avvia i controlli
        string er = "";

        if (tNikname.Text.Length < 7 || tNikname.Text.Trim().Length > 24)
        {
            er += "Username con almeno 8 caratteri (max 24); ";
        }
        if (tNome.Text.Length < 2)
        {
            er += "Nome con almeno 3 caratteri; ";
        }
        if (tCognome.Text.Length < 2)
        {
            er += "Cognome con almeno 3 caratteri; ";
        }
        if (tMail1.Text.Length < 6 || (tMail1.Text.IndexOf("@") < 1) || (tMail1.Text.IndexOf(".") < 1))
        {
            er += "E-Mail con almeno 7 caratteri e con il simbolo @ e il simbolo . ; ";
        }
        if (tMail1.Text != tMail2.Text)
        {
            er += "E-Mail e Conferma E-Mail; ";
        }
        //if (tMatricola.Text.Length < 4) er += "Matricola; ";
        if (cbNonPresente.Checked)         // ente non presente    -> può essere che ddlselezionato ma nonpresente = vero!!!!!
        {
            if (tEnte.Text.Trim().Length < 3)
            {
                er += "Ente con almeno 3; ";
            }
        }
        else
        if (ddlEnte.SelectedItem.Text.Trim().Length < 2)
        {
            er += "Ente non selezionato; ";
        }
        if (tIndirizzo.Text.Length < 5)
        {
            er += "Indirizzo con almeno 6 caratteri; ";
        }
        if (tCivico.Text.Trim().Length < 1)
        {
            er += "Civico; ";
        }
        if (tCap.Text.Trim().Length < 5)
        {
            er += "Cap con almeno 6 caratteri; ";
        }
        if (tCitta.Text.Trim().Length < 2)
        {
            er += "Città con almeno 3 caratteri; ";
        }
        if (tTelefono.Text.Trim().Length < 8)
        {
            er += "Telefono con almeno 9 caratteri; ";
        }
        if (tTelefono.Text.IndexOf(" ") > 0)
        {
            er += "Telefono: solo numeri senza spazi; ";
        }
        if (!cbConsenso.Checked)
        {
            er += "Consenso al trattamento: è necessario; ";
        }
        if (cbNonPresente.Checked && tEnte.Text.Trim().Length < 3)
        {
            er += "Ente: con almeno 3 caratteri; ";
        }
        if (!cbNonPresente.Checked && ddlEnte.SelectedItem.Text.Trim().Length < 2)
        {
            er += "Ente: con almeno 2 caratteri; ";
        }
        if (er != "")
        {
            er          = "I valori dei campi indicati sono errati o mancanti: " + er;
            tStato.Text = er;
            return;
        }
        utente.nikname = tNikname.Text.Trim();
        utente.nome    = tNome.Text.Trim();
        utente.cognome = tCognome.Text.Trim();
        utente.mail    = tMail1.Text.Trim();
        //utente.matricola = tMatricola.Text.Trim();
        utente.ente        = cbNonPresente.Checked ? tEnte.Text.Trim() : ddlEnte.SelectedItem.Text.Trim();
        utente.ente_ek     = "";
        utente.tipoente_ek = "";
        Gare gara = new Gare();

        tbl = gara.CercaEnte(null, utente.ente, out msg);
        if (tbl != null && tbl.Rows[0]["tipoente_ek"] != DBNull.Value)
        {
            utente.tipoente_ek = tbl.Rows[0]["tipoente_ek"].ToString().Trim();
        }
        utente.indirizzo = tIndirizzo.Text.Trim();
        utente.civico    = tCivico.Text.Trim();
        utente.cap       = tCap.Text.Trim();
        utente.città     = tCitta.Text.Trim();
        utente.telefono  = tTelefono.Text.Trim();
        utente.scadenza  = DateTime.Now.AddMonths(12);

        // non ci sono errori di inserimento e posso registrare la richiesta o la modifica
        if (id > 0)         // è una modifica
        {
            bool ok = utente.registradatiutente("Modifica anagrafica utente", (Int32)id);
            if (!ok)
            {
                tStato.Text = "Modifiche non apportate. Contattare il servizio assistenza al n. " + Session["assistenza"].ToString();
                return;
            }
            Response.Redirect("menu.aspx?p=" + utente.iduser.ToString().Trim() + "&l=si");
        }
        else
        {   // devo controllare se l'utente c'è già, se no lo registro ed invio mail di richiesta registrazione ed abilitazione
            // poi ritorno alla pagina di default con loggato = no
            DataSet ds = new DataSet();
            SQLClass.SQLc.Parameters.Clear();
            SQLClass.SQLc.Parameters.Add("@nikname", SqlDbType.NVarChar); SQLClass.SQLc.Parameters["@nikname"].Value = System.Convert.ToString(utente.nikname);
            if (SQLClass.getSQLdata("select * from utenti where nikname=@nikname", "utenti", out msg) > 0)
            {
                tStato.Text = "Utente con username " + utente.nikname + " già presente. Accertarsi di non essere già stati registrati o cambiare Username!";
                //ShowPopUpMsg("Utente con username " + utente.nikname + " già presente. Accertarsi di non essere già stati registrati o cambiare Username!");
                return;
            }
            else
            {
                utente.password            = utente.CalcolaPasswordCasuale(8, 3, 3, 3);
                utente.abilitato           = false;
                utente.forzocambiopassword = true;
                utente.giornalizza         = false;
                //utente.ente = (utente.ente);
                if (utente.aggiungiutente())
                {
                    // ok registrazione effettuata. ora manda mail agli amministratori
                    // devo rileggere il record aggiunto per avere l'id
                    if (!utente.cercanikname(utente.nikname, utente.password))
                    {
                        tStato.Text = "Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"];
                        return;
                        //ShowPopUpMsg("Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"]);
                    }

                    Session.Add("Utente", utente.nikname);
                    Session.Add("iduser", utente.iduser);

                    // inoltro mail a tutti gli amministratori

                    msg = "";
                    ds.Clear();
                    tbl = SQLClass.getfromDSet("select id, nikname, nome, cognome, mail, power from utenti where (power >= 50)", "Admin", out msg);
                    if (msg.Trim() != "")
                    {
                        tStato.Text = "Attenzione: problema di connessione. Prego contattare il n. " + (string)Session["assistenza"];
                        return;
                    }
                    int      k = 0, n = tbl.HasErrors ? 0 : tbl.Rows.Count;
                    string[] achisccn = new string[n];
                    string[] achi     = new string[1];
                    achi[0] = utente.mail;

                    for (int i = 0; i < n; i++)
                    {
                        if (tbl.Rows[i]["Mail"] != DBNull.Value)
                        {
                            achisccn[k++] = tbl.Rows[i]["Mail"].ToString();
                        }
                    }
                    if (k == 0)
                    {
                        tStato.Text = "Attenzione: non ci sono amministratori che posso confermare la tua richiesta. Prego contattare il n. " + (string)Session["assistenza"];
                        //ShowPopUpMsg("Attenzione: non ci sono amministratori che posso confermare la tua richiesta. Prego contattare il n. " + (string)Session["assistenza"]);
                    }
                    else
                    {
                        gmail gm = null;
                        gm = new gmail();
                        gm.dachivisualizzato = "Agenzia prov. pre gli Appalti e Contratti";
                        gm.achi      = achi;
                        gm.achiccn   = achisccn;
                        gm.numeritel = "0461-496456";
                        gm.subject   = "Raccolta fabbisogno: richiesta registrazione nuovo utente";
                        gm.body      = "Buongiorno,\n";
                        gm.body     += "\tla informaiamo che la sua domanda di registrazione all'applicazione web\n";
                        gm.body     += "per la presentazione delle richieste di gara per le quali s'intende avvalersi\n";
                        gm.body     += "dei servizi offerti da APAC è stata inoltrata correttamente.\n";
                        gm.body     += "\n\nI dati inseriti sono:\n";
                        gm.body     += "Username:          \t" + utente.nikname + "\n";
                        gm.body     += "Nome:              \t" + utente.nome + "\n";
                        gm.body     += "Cognome:           \t" + utente.cognome + "\n";
                        gm.body     += "Mail:              \t" + utente.mail + "\n";
                        gm.body     += "Tel.:              \t" + utente.telefono + "\n\n\n";
                        gm.body     += "Dopo l'approvazione, riceverà automaticamente la mail con le credenziali per il primo accesso.\n\n";
                        gm.body     += "Cordiali saluti.\n";
                        if (!gm.mandamail("", 0, "", "", out msg))
                        {
                            tStato.Text = "Richiesta di registrazione non eseguita! MAIL DI CONFERMA NON INOLTRATA!. CONTATTARE IL NUMERO " + (string)Session["assistenza"] + " Err: " + msg;
                            //ShowPopUpMsg("Richiesta di registrazione effettuata con successo, MAIL DI CONFERMA NON INOLTRATA!. CONTATTARE IL NUMERO " + (string)Session["assistenza"] + " Err: " + msg);
                        }
                        else
                        {
                            tStato.Text          = "Richiesta di registrazione effettuata con successo. Riceverà via email le credenziali per l'accesso.";
                            cbRegistrati.Enabled = false;
                            //ShowPopUpMsg("Richiesta di registrazione effettuata con successo. Riceverà, entro 24 ore via email, le credenziali per l'accesso.");
                        }
                    }
                }
                else
                {
                    tStato.Text = "Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"];
                }
            }
        }
    }