Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Murkrow02/Salvemini
Browse files Browse the repository at this point in the history
# Conflicts:
#	.DS_Store
  • Loading branch information
xV4L3x committed May 12, 2021
2 parents 5dbac31 + f87034a commit d955b16
Show file tree
Hide file tree
Showing 54 changed files with 3,994 additions and 3,354 deletions.
Binary file modified SalveminiApiCore/.DS_Store
Binary file not shown.
Binary file modified SalveminiApiCore/SalveminiApi core/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;

namespace SalveminiApi_core.Models
{
public partial class FondoStudentesco
{
public long Id { get; set; }
public string Causa { get; set; }
public DateTime Data { get; set; }
public decimal Importo { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public class IndexModel
public Giornalino Giornalino { get; set; }
public int Authorized { get; set; }
public bool VotedSondaggio { get; set; }
public int sCoin { get; set; }
public decimal Fondo { get; set; }
public string Classe { get; set; }
public string Corso { get; set; }
public string LiveLink { get; set; }
}

public class IndexArgo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public Salvemini_DBContext(DbContextOptions<Salvemini_DBContext> options)
public virtual DbSet<FlappyClassifica> FlappyClassifica { get; set; }
public virtual DbSet<FlappyMonete> FlappyMonete { get; set; }
public virtual DbSet<FlappySkin> FlappySkin { get; set; }
public virtual DbSet<FondoStudentesco> FondoStudentesco { get; set; }
public virtual DbSet<Giornalino> Giornalino { get; set; }
public virtual DbSet<Materie> Materie { get; set; }
public virtual DbSet<Notifiche> Notifiche { get; set; }
Expand Down Expand Up @@ -383,6 +384,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(150);
});

modelBuilder.Entity<FondoStudentesco>(entity =>
{
entity.Property(e => e.Id).HasColumnName("id");

entity.Property(e => e.Causa)
.IsRequired()
.HasMaxLength(2000);

entity.Property(e => e.Data).HasColumnType("datetime");

entity.Property(e => e.Importo).HasColumnType("money");
});

modelBuilder.Entity<Giornalino>(entity =>
{
entity.Property(e => e.Id).HasColumnName("id");
Expand Down Expand Up @@ -472,10 +486,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(150);

entity.HasOne(d => d.Utenti)
.WithMany(p => p.Sondaggi)
.HasForeignKey(d => d.Creatore)
.OnDelete(DeleteBehavior.NoAction)
.HasConstraintName("FK_Sondaggi_Utenti");
.WithMany(p => p.Sondaggi)
.HasForeignKey(d => d.Creatore)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Sondaggi_Utenti");
});

modelBuilder.Entity<Utenti>(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public Sondaggi()

public virtual ICollection<OggettiSondaggi> OggettiSondaggi { get; set; }
public virtual ICollection<VotiSondaggi> VotiSondaggi {internal get; set; }

public virtual Utenti Utenti { get; set; }
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task<IActionResult> UpdateUsers()
}


[Route("login")]
[Route("login")]
[HttpPost]
public async Task<IActionResult> Auth(AuthBlock authBlock)
{
Expand All @@ -85,8 +85,7 @@ public async Task<IActionResult> Auth(AuthBlock authBlock)
var client = new HttpClient();
var response = new HttpResponseMessage();
string content = "";
if (authBlock.username != "mariateresafiorentino")
{

client.DefaultRequestHeaders.Add("x-app-code", "APF");
client.DefaultRequestHeaders.Add("x-cod-min", "SS16836");
client.DefaultRequestHeaders.Add("x-key-app", Costants.argoKey);
Expand All @@ -112,9 +111,10 @@ public async Task<IActionResult> Auth(AuthBlock authBlock)
if (!response.IsSuccessStatusCode)
return StatusCode(500);

content = await response.Content.ReadAsStringAsync();
}
string Token = authBlock.username == "mariateresafiorentino" ? "7e3d3f15-2c66-413f-a6b0-01534a2b4d94.11" : JsonConvert.DeserializeObject<AuthResponse>(content).token;
content = await response.Content.ReadAsStringAsync();


string Token = JsonConvert.DeserializeObject<AuthResponse>(content).token;

//Prendi schede
var argoUtils = new ArgoUtils();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public IActionResult getAvvisi()
var avvisi = db.Avvisi.OrderByDescending(x => x.Creazione).ToList();

//Aggiungi visualizzazione ad analytics
try { db.Analytics.FirstOrDefault(x => x.Tipo == "UltimoAvviso").Valore = db.Analytics.FirstOrDefault(x => x.Tipo == "UltimoAvviso").Valore + 1; db.SaveChanges(); } catch { }




if (avvisi == null || avvisi.Count < 1)
return NotFound();

Expand Down Expand Up @@ -66,7 +71,7 @@ public IActionResult addAvviso(Avvisi avviso)
avviso.Creazione = Utility.italianTime();
db.Avvisi.Add(avviso);
//Remove previous avvisi visual
try { db.Analytics.ToList().RemoveAll(x => x.Tipo == "UltimoAvviso"); } catch { }
try { db.Analytics.FirstOrDefault(x => x.Tipo == "UltimoAvviso").Valore = 0; } catch { }
db.SaveChanges();
}
catch(Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ public IActionResult getGiornalino(string id)

try
{
var stream = System.IO.File.OpenRead(_env.WebRootPath + "/Giornalino/" + id + ".pdf");
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(stream);

response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentLength = stream.Length;

return Ok(response);
var stream = new FileStream(_env.WebRootPath + "/Giornalino/" + id + ".pdf", FileMode.Open);
return new FileStreamResult(stream, "application/pdf");
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public IActionResult AddTransaction([FromBody] FondoStudentesco transaction)
//Add transaction in db
transaction.Data = Utility.italianTime();
db.FondoStudentesco.Add(transaction);
db.SaveChanges();

//Success
return Ok("Transazione aggiunta con successo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Newtonsoft.Json;
using SalveminiApi_core.Argo.Models;
using SalveminiApi_core.Models;
using SalveminiApi_core.OneSignalApi;

namespace SalveminiApi_core.Controllers
{
Expand Down Expand Up @@ -61,10 +62,16 @@ public async Task<IActionResult> GetIndex()
returnModel.OrarioTrasportiVersion = appInfo.OrariVersion;
}


//sCoin
//Fondo
returnModel.Fondo = CalcolaFondo();

//Live stream link
var LastStream = db.LiveLink.Where(x => Utility.italianTime().AddHours(-2) < x.CreatedOn).ToList();
if(LastStream != null && LastStream.Count() > 0)
{
returnModel.LiveLink = LastStream.FirstOrDefault().Link;
}

//Classe
returnModel.Classe = utente.Classe.ToString();
returnModel.Corso = utente.Corso;
Expand Down Expand Up @@ -107,10 +114,7 @@ public async Task<IActionResult> GetIndex()
returnModel.ultimoSondaggio = null;
}




//ADS
//Ads
var adsList = new List<Ads>();
var interstitial = db.Ads.Where(x => x.Tipo == 1).ToList();
var banner = db.Ads.Where(x => x.Tipo == 0).ToList();
Expand All @@ -135,9 +139,10 @@ public async Task<IActionResult> GetIndex()
db.Ads.Find(interstitial[rInt]).Impressions++;
}

//Save ad downloads
//Save access in analytics
try
{
try { db.Analytics.FirstOrDefault(x => x.Tipo == "Accessi").Valore = db.Analytics.FirstOrDefault(x => x.Tipo == "Accessi").Valore + 1; db.SaveChanges(); } catch { }
db.SaveChanges();
}
catch
Expand All @@ -149,6 +154,39 @@ public async Task<IActionResult> GetIndex()
return Ok(returnModel);
}

[Route("live")]
[HttpPost]
public IActionResult PostLiveLink([FromBody] LiveLink liveLink)
{
//Check Auth
bool authorized = AuthHelper.Authorize(Request, db, 3);
if (!authorized)
return Unauthorized();

//Create live link on db
liveLink.CreatedOn = Utility.italianTime();
db.LiveLink.Add(liveLink);
db.SaveChanges();

//Send notification
try
{
var notifica = new NotificationModel();
var titolo = new Localized { en = "Siamo in diretta! 🔴" };
var dettagli = new Localized { en = $"{liveLink.Title}, apri l'app per entrare subito nella live (assicurati di avere l'ultimo aggiornamento)" };
notifica.headings = titolo;
notifica.contents = dettagli;
NotificationService.sendNotification(notifica);
}
catch
{
//Errore nell inviare la notifica, ma fa niente lol avviso creato con successo
return Ok();
}

return Ok();
}


[Route("giornalini")]
[HttpGet]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public IActionResult postCommento([FromBody]Commenti commento_)
var dettagli = new Localized { en = desc };
var filter = new Tags { field = "tag", key = "Secrets", relation = "=", value = post.IdUtente.ToString() };
var tags = new List<Tags>();
var data = new AdditionalData { tipo = "push", id = "iCringe" }; tags.Add(filter);
var data = new AdditionalData { tipo = "push", id = "iCringe" };
tags.Add(filter);
notifica.headings = titolo;
notifica.contents = dettagli;
notifica.data = data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,2 @@
Server=68.168.220.50;Database=Salvemini_DB;User Id=Salvemini_DB;Password=Ctpb09~1
Scaffold-DbContext "Data Source=68.168.220.50;Initial Catalog=Salvemini_DB;Persist Security Info=True;User ID=Salvemini_DB;Password=Ctpb09~1" Microsoft.EntityFrameworkCore.SqlServer -Verbose -OutputDir Models -force

using System;
using System.Collections.Generic;

namespace SalveminiApi_core.Models
{
public partial class Utenti
{
public Utenti()
{
Avvisi = new HashSet<Avvisi>();
CoinGuadagnate = new HashSet<CoinGuadagnate>();
CoinSpese = new HashSet<CoinSpese>();
Commenti = new HashSet<Commenti>();
Coupon = new HashSet<Coupon>();
CouponAttivi = new HashSet<CouponAttivi>();
Notifiche = new HashSet<Notifiche>();
VotiSondaggi = new HashSet<VotiSondaggi>();
}

public int Id { get; set; }
public string Nome { get; set; }
public string Cognome { get; set; }
public string Sesso { get; set; }
public int Classe { get; set; }
public string Corso { get; set; }
public int Stato { get; set; }
public DateTime Creazione { get; set; }
public int SCoin { get; set; }
public int AdsWatched { get; set; }
public DateTime? LastAdWatched { get; set; }
public string Immagine { get; set; }
public string ArgoToken { get; set; }

public virtual FlappyClassifica FlappyClassifica { internal get; set; }
public virtual ICollection<Avvisi> Avvisi { internal get; set; }
public virtual ICollection<CoinGuadagnate> CoinGuadagnate { internal get; set; }
public virtual ICollection<CoinSpese> CoinSpese { internal get; set; }
public virtual ICollection<Commenti> Commenti { internal get; set; }
public virtual ICollection<Coupon> Coupon { internal get; set; }
public virtual ICollection<CouponAttivi> CouponAttivi { internal get; set; }
public virtual ICollection<Notifiche> Notifiche { internal get; set; }
public virtual ICollection<VotiSondaggi> VotiSondaggi { internal get; set; }
}
}
Server=69.10.59.218;Database=Salvemini_DB;User Id=Salvemini_DB;Password=gr2HNvpd9FRh
Scaffold-DbContext "Data Source=69.10.59.218;Initial Catalog=Salvemini_DB;Persist Security Info=True;User ID=Salvemini_DB;Password=gr2HNvpd9FRh" Microsoft.EntityFrameworkCore.SqlServer -Verbose -OutputDir Models -force
Loading

0 comments on commit d955b16

Please sign in to comment.