Beispiel #1
0
 //
 // GET: /Home/
 public ActionResult Index()
 {
     NotizieManager newsM = new NotizieManager(DatabaseContext);
     PersonaggiManagerNew pgM = new PersonaggiManagerNew(DatabaseContext);
      NotizieModel news = new NotizieModel();
      HomeModel model = new HomeModel();
     if (User.Identity.Name != null && User.Identity.Name != "")
     {
         Personaggio pg = pgM.GetCharacterByNumber(long.Parse(User.Identity.Name));
         news = newsM.GetActiveNewsInModel((long)pg.Fazione, DateTime.Now);
         switch((long)pg.Fazione)
         {
             case 0:
                 model.css = "main.css";
                 break;
             case 1:
             case 2:
             case 3:
                 model.css ="main-impero.css";
             break;
         }
     }
     else
     {
        news = newsM.GetActiveNewsInModel(0, DateTime.Now);
     }
     model.notizie = news;
        return View(model);
 }
Beispiel #2
0
 private void btnSalva_Click(object sender, EventArgs e)
 {
     if (ValidateForm())
     {
         DialogResult res = MessageBox.Show("Stai per inviare la notizia: sei sicuro?", "Conferma invio", MessageBoxButtons.YesNo);
         if (res == System.Windows.Forms.DialogResult.Yes)
         {
             long autore = (long)cmbAutore.SelectedValue;
             long rete = (long)cmbFazione.SelectedValue;
             DateTime inizio = dtCreazione.Value;
             DateTime fine = dtFine.Value;
             long hacking = (long)numHacking.Value;
             using (databaseContext = CreateDatabaseContext())
             {
                 NotizieManager manager = new NotizieManager(databaseContext);
                 bool result = false;
                 if (numeroNotizia == null)
                 {
                     result = manager.SendNews(txtOggetto.Text.Trim(), txtTesto.Text.Trim(), inizio, fine, rete, autore, hacking);
                 }
                 else
                 {
                     result = manager.UpdateNews(numeroNotizia.Value, txtOggetto.Text.Trim(), txtTesto.Text.Trim(), inizio, fine, rete, autore, hacking);
                 }
                 if (result)
                 {
                     databaseContext.SaveChanges();
                     MessageBox.Show("Notizia inviata correttamente");
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("C'è stato un errore durante il salvataggio");
                 }
             }
         }
     }
 }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteMaster)this.Page.Master).FindControl("NavigationMenu").Visible = false;
            if (!IsPostBack)
            {
                pageViews.SetActiveView(viewNotizia);
                long accountInfranto = (long)Session["AccountInfranto"];

                var account = (from personaggio in DatabaseContext.Personaggios
                                where personaggio.NumeroPG == accountInfranto
                                select personaggio).First();

                lblNomeProprietario.Text = account.Nome;
                if (account.Hacker.HasValue && account.Hacker > 1)
                {
                    livelloHacking = (long)account.Hacker;
                }
                else
                {
                    livelloHacking = 1;
                }

                //caricamento notizie
                int numeroRete = reteHack;
                NotizieManager manager = new NotizieManager(DatabaseContext);
                var elencoNotizie = manager.GetActiveNewsIndexes(numeroRete, DateTime.Now);

                if (elencoNotizie.Count() > 0)
                {
                    NewsCollection = elencoNotizie.ToArray();
                    tblContent.Visible = true;
                }
                else
                {
                    tblContent.Visible = false;
                }
                PosizioneLettura = 0;
                ShowNotizia();
            }
        }
Beispiel #4
0
 protected void btnModifica_Click(object sender, EventArgs e)
 {
     NotizieManager manager = new NotizieManager(DatabaseContext);
     Notizia elementToEdit = manager.GetSingleNewsItem(NewsCollection[PosizioneLettura]);
     hackControl.LivelloHacking = elementToEdit.LivelloHacking;
     hackControl.IdentificatoreElemento = NewsCollection[PosizioneLettura];
     hackControl.Carica();
     pageViews.SetActiveView(viewHacking);
 }
Beispiel #5
0
 protected void btnInvia_Click(object sender, EventArgs e)
 {
     NotizieManager manager = new NotizieManager(DatabaseContext);
     Notizia elementToEdit = manager.GetSingleNewsItem(NewsCollection[PosizioneLettura]);
     manager.UpdateNews(elementToEdit.NumeroNotizia, txtOggetto.Text.Trim(), txtTesto.Text.Trim(), elementToEdit.DataCreazione, elementToEdit.DataFine, elementToEdit.Rete, elementToEdit.Autore.Value, elementToEdit.LivelloHacking);
     DatabaseContext.SaveChanges();
     pageViews.SetActiveView(viewNotizia);
     ShowNotizia();
 }
Beispiel #6
0
 public void OnHackedSuccess(long hackerAccount)
 {
     pageViews.SetActiveView(viewEditor);
     NotizieManager manager = new NotizieManager(DatabaseContext);
     Notizia elementToEdit = manager.GetSingleNewsItem(NewsCollection[PosizioneLettura]);
     txtOggetto.Text = elementToEdit.Titolo;
     txtTesto.Text = elementToEdit.Testo;
 }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Rete"] != null)
            {

                if (!IsPostBack)
                {
                    this.Page.Header.Title = "NOTIZIE";
                    int numeroRete = int.Parse(Session["Rete"].ToString());

                    NotizieManager manager = new NotizieManager(DatabaseContext);

                    //var elencoNotizie = (from notizie in DatabaseContext.Notizias
                    //                        where notizie.Rete == numeroRete
                    //                        where notizie.DataFine >= DateTime.Today
                    //                        where notizie.DataCreazione <= DateTime.Today
                    //                        orderby notizie.DataCreazione
                    //                        select notizie.NumeroNotizia).Distinct();
                    DateTime dataOdierna = DateTime.Now;
                    var elencoNotizie = manager.GetActiveNewsIndexes(numeroRete, dataOdierna);

                    PosizioneLettura = 0;
                    if (elencoNotizie.Count() > 0)
                    {
                        NewsCollection = elencoNotizie.ToArray();
                        panelNotizie.Visible = true;
                        ShowNotizia();                        }
                    else
                    {
                        panelNotizie.Visible = false;
                    }

                }
            }
        }
Beispiel #8
0
        private void ShowNotizia()
        {
            if (PosizioneLettura < 0)
            {
                PosizioneLettura = 0;
            }
            if (PosizioneLettura >= NewsCollection.Length)
            {
                PosizioneLettura = NewsCollection.Length -1;
            }
            if (PosizioneLettura < NewsCollection.Length)
            {
                long numNotizia = NewsCollection[PosizioneLettura];
                NotizieManager newsManager = new NotizieManager(DatabaseContext);
                PersonaggiManagerNew characterManager = new PersonaggiManagerNew(DatabaseContext);
                //var notizia = (from notizie in DatabaseContext.Notizias
                //                where notizie.NumeroNotizia == numNotizia
                //                select notizie).First();
                Notizia notizia = newsManager.GetSingleNewsItem(numNotizia);
                //var persAutore = (from personaggio in DatabaseContext.Personaggios
                //                    where personaggio.NumeroPG == notizia.Autore
                //                    select personaggio).First();
                Personaggio persAutore = characterManager.GetCharacterByNumber(notizia.Autore.Value);
                lblAutore.Text = persAutore.Nome;
                lblDataNotizia.Text = notizia.DataCreazione.ToString();
                lblTitoloNotizia.Text = notizia.Titolo;
                lblTestoNotizia.Text = notizia.Testo;

                //Ora imposto un'immagine di cronista a caso
                Random randomizer = new Random();
                int immagineCronista = randomizer.Next(1, 33);
                facePicture.ImageUrl = "~/Images/Volti/" + immagineCronista.ToString() + ".jpg";
            }
        }
Beispiel #9
0
 private void grdNotizie_SelectionChanged(object sender, EventArgs e)
 {
     if (grdNotizie.SelectedRows.Count == 1)
     {
         long numeroMissione = (long)grdNotizie.SelectedRows[0].Cells["NumeroNotizia"].Value;
         using (databaseContext = CreateDatabaseContext())
         {
             NotizieManager manager = new NotizieManager(databaseContext);
             PersonaggiManagerNew charManager = new PersonaggiManagerNew(databaseContext);
             Notizia singleNew = manager.GetSingleNewsItem(numeroMissione);
             Personaggio autore = charManager.GetCharacterByNumber(singleNew.Autore.Value);
             txtTesto.Text = "AUTORE: " + autore.Nome + "\r\n \r\n";
             txtTesto.Text += singleNew.Testo.Replace("<br />", "\r\n");
         }
     }
 }
Beispiel #10
0
 private void LoadNews()
 {
     txtTesto.Text = string.Empty;
     if (cmbFazione.SelectedValue != null)
     {
         long rete = (long)cmbFazione.SelectedValue;
         DateTime data = dtVisualizzazione.Value;
         using (databaseContext = CreateDatabaseContext())
         {
             NotizieManager manager = new NotizieManager(databaseContext);
             IList<Notizia> notizie;
             if (chkAll.Checked)
             {
                 notizie = manager.GetNews(rete);
             }
             else
             {
                 notizie = manager.GetNews(rete, data);
             }
             grdNotizie.DataSource = notizie;
         }
     }
 }
Beispiel #11
0
 protected void btnInvia_Click(object sender, EventArgs e)
 {
     NotizieManager manager = new NotizieManager(DatabaseContext);
     manager.SendNews(txtOggetto.Text.Trim(), txtTesto.Text.Trim(), DateTime.Now, calScadenza.SelectedDate, Rete, LoggedCharacter.NumeroPG, LoggedCharacter.LivelloCrittazione);
     DatabaseContext.SaveChanges();
     lblSuccess.Visible = true;
     PageViews.SetActiveView(viewEmpty);
 }
Beispiel #12
0
 private void LoadSingleNews()
 {
     if (numeroNotizia != null)
     {
         using (databaseContext = CreateDatabaseContext())
         {
             NotizieManager newsManager = new NotizieManager(databaseContext);
             Notizia newsToEdit = newsManager.GetSingleNewsItem(numeroNotizia.Value);
             txtOggetto.Text = newsToEdit.Titolo;
             cmbAutore.SelectedValue = newsToEdit.Autore;
             cmbFazione.SelectedValue = newsToEdit.Rete;
             txtTesto.Text = newsToEdit.Testo.Replace("<br />", "\r\n");
             dtCreazione.Value = newsToEdit.DataCreazione;
             dtFine.Value = newsToEdit.DataFine;
             numHacking.Value = newsToEdit.LivelloHacking;
         }
     }
 }